<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Google OAuth 2.0 и YouTube API]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=14569&amp;type=atom" />
	<updated>2023-01-18T18:34:43Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=14569</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Google OAuth 2.0 и YouTube API]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=156433#p156433" />
			<content type="html"><![CDATA[<p>Кстати, если нам надо получить доступ к нескольким scope, тои их надо перечислять через пробел и без слеша в конце:<br /></p><div class="codebox"><pre><code>scope := &quot;https://mail.google.com https://www.googleapis.com/auth/calendar&quot;</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2023-01-18T18:34:43Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=156433#p156433</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Google OAuth 2.0 и YouTube API]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=137218#p137218" />
			<content type="html"><![CDATA[<p>Не знаю почему у вас не приходит.<br />Должен приходить.<br /><a href="https://developers.google.com/android-publisher/authorization">https://developers.google.com/android-p … horization</a></p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2020-01-10T14:34:06Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=137218#p137218</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Google OAuth 2.0 и YouTube API]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=137209#p137209" />
			<content type="html"><![CDATA[<p>Примерно такой:</p><div class="codebox"><pre><code>{
  &quot;access_token&quot;: &quot;ya29.Il-4Bw5mszyLdRC5UXoj4eleUrY5GyZCwaXlJgq_p_TdolJQervhDkeSfdkWd7Q-uvhiUipScnR5uxFhwf9aIzHqFHCdty5rTvBj4Yp54LO0ESyQ2SiNY7t05VxF097O5Q&quot;,
  &quot;expires_in&quot;: 3600,
  &quot;scope&quot;: &quot;https://www.googleapis.com/auth/youtube&quot;,
  &quot;token_type&quot;: &quot;Bearer&quot;
}
</code></pre></div>]]></content>
			<author>
				<name><![CDATA[svoboden]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=34280</uri>
			</author>
			<updated>2020-01-10T00:09:09Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=137209#p137209</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Google OAuth 2.0 и YouTube API]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=137208#p137208" />
			<content type="html"><![CDATA[<p>А какой приходит ответ?<br /></p><div class="codebox"><pre><code>; изменяем данные
ClientId := &quot;341870872-dgbbg66.apps.googleusercontent.com&quot;
ClientSecret := &quot;JJN1OS7110v-j&quot;
AuthorizationCode := &quot;4/7wCaeBV61IBslGg5pU9AZZ-XvrtJp7Dmnfh_khOlv6Co-sUuL0OMd7jt5s&quot;

; дальше не изменяем
RedirectUri := &quot;http://localhost&quot;
Request := &quot;grant_type=authorization_code&amp;code=&quot; AuthorizationCode &quot;&amp;redirect_uri=&quot; UriEncode(RedirectUri) &quot;&amp;client_id=&quot; ClientId &quot;&amp;client_secret=&quot; ClientSecret
WinHTTP := ComObjCreate(&quot;WinHTTP.WinHTTPRequest.5.1&quot;)
WinHTTP.Open(&quot;POST&quot;, &quot;https://accounts.google.com/o/oauth2/token&quot;, true)
WinHTTP.SetRequestHeader(&quot;Content-Type&quot;, &quot;application/x-www-form-urlencoded&quot;)
WinHTTP.Send(Request)
WinHTTP.WaitForResponse()
msgbox % clipboard := WinHTTP.ResponseText

UriEncode(Uri)
{
   VarSetCapacity(Var, StrPut(Uri, &quot;UTF-8&quot;), 0)
   StrPut(Uri, &amp;Var, &quot;UTF-8&quot;)
   f := A_FormatInteger
   SetFormat, IntegerFast, H
   While Code := NumGet(Var, A_Index - 1, &quot;UChar&quot;)
      If (Code &gt;= 0x30 &amp;&amp; Code &lt;= 0x39 ; 0-9
         || Code &gt;= 0x41 &amp;&amp; Code &lt;= 0x5A ; A-Z
         || Code &gt;= 0x61 &amp;&amp; Code &lt;= 0x7A) ; a-z
         Res .= Chr(Code)
      Else
         Res .= &quot;%&quot; . SubStr(Code + 0x100, -1)
   SetFormat, IntegerFast, %f%
   Return, Res
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2020-01-09T23:40:54Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=137208#p137208</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Google OAuth 2.0 и YouTube API]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=137207#p137207" />
			<content type="html"><![CDATA[<p>Да, я же поэтому и пишу, что не пришел токен обновления по инструкции.</p>]]></content>
			<author>
				<name><![CDATA[svoboden]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=34280</uri>
			</author>
			<updated>2020-01-09T19:00:46Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=137207#p137207</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Google OAuth 2.0 и YouTube API]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=137206#p137206" />
			<content type="html"><![CDATA[<p>А аы делали по алгоритму из первого поста?</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2020-01-09T18:30:23Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=137206#p137206</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Google OAuth 2.0 и YouTube API]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=137205#p137205" />
			<content type="html"><![CDATA[<p>Ну у меня не приходит Refresh Token без параметра access_type=offline.</p>]]></content>
			<author>
				<name><![CDATA[svoboden]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=34280</uri>
			</author>
			<updated>2020-01-09T18:20:01Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=137205#p137205</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Google OAuth 2.0 и YouTube API]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=137204#p137204" />
			<content type="html"><![CDATA[<p>Я не понимаю, что именно вы не понимаете.<br />В первом сообщении написано, как получить Access Token и Refresh Token.<br />Во втором, как получить новый Access Token.<br />Только что проверил - всё работает.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2020-01-09T18:07:15Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=137204#p137204</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Google OAuth 2.0 и YouTube API]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=137203#p137203" />
			<content type="html"><![CDATA[<p>Ну да, токен обновления приходит только раз, потом нужно снова регистрировать приложение. Немного не понял, так без параметра:<br /></p><div class="codebox"><pre><code>access_type=offline</code></pre></div><p> токен обновления вообще не придет.</p>]]></content>
			<author>
				<name><![CDATA[svoboden]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=34280</uri>
			</author>
			<updated>2020-01-09T17:41:07Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=137203#p137203</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Google OAuth 2.0 и YouTube API]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=137199#p137199" />
			<content type="html"><![CDATA[<p>А зачем вам нужен новый refresh token?<br />Он же постоянный. По вашей ссылке:<br /></p><div class="quotebox"><blockquote><p>Refresh tokens are valid until the user revokes access</p></blockquote></div><p>Мой же код из 2 поста получает новый access_token.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2020-01-09T13:10:45Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=137199#p137199</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Google OAuth 2.0 и YouTube API]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=137198#p137198" />
			<content type="html"><![CDATA[<p>Просто там прям в <a href="https://developers.google.com/identity/protocols/OAuth2WebServer?hl=ru#exchange-authorization-code">справке</a> написано, что:<br /></p><div class="quotebox"><blockquote><p>Note that the refresh token is only returned if your application set the access_type parameter to offline in the initial request to Google&#039;s authorization server.</p></blockquote></div><p>Вот так придет токен обновления:<br /></p><div class="codebox"><pre><code>msgbox % clipboard := &quot;https://accounts.google.com/o/oauth2/auth?redirect_uri=&quot; UriEncode(RedirectUri) &quot;&amp;response_type=code&amp;client_id=&quot; ClientId &quot;&amp;scope=&quot; UriEncode(scope) &quot;&amp;access_type=offline&quot; &quot;&amp;include_granted_scopes=true&quot; &quot;&amp;state=state_parameter_passthrough_value&quot; &quot;&amp;clientSecret=&quot; ClientSecret &quot;&amp;approval_prompt=force&quot;</code></pre></div>]]></content>
			<author>
				<name><![CDATA[svoboden]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=34280</uri>
			</author>
			<updated>2020-01-09T12:30:10Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=137198#p137198</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Google OAuth 2.0 и YouTube API]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=137196#p137196" />
			<content type="html"><![CDATA[<p>Первый и последний раз я пробовал обновлять токен год назад, когда и написал тот пост.<br />Тогда у меня приходил.<br />Возможно в каких-то случаях и не приходит - я не углублялся.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2020-01-07T13:51:10Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=137196#p137196</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Google OAuth 2.0 и YouTube API]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=137195#p137195" />
			<content type="html"><![CDATA[<p>Так нет параметра: </p><div class="codebox"><pre><code>access_type=offline</code></pre></div><p>Токен обновления не придет.</p>]]></content>
			<author>
				<name><![CDATA[svoboden]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=34280</uri>
			</author>
			<updated>2020-01-07T13:32:05Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=137195#p137195</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Google OAuth 2.0 и YouTube API]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=132178#p132178" />
			<content type="html"><![CDATA[<p>Обновлять токен так:<br /></p><div class="codebox"><pre><code>; изменяем данные
ClientId := &quot;341870872-dgbbg66.apps.googleusercontent.com&quot;
ClientSecret := &quot;JJN1OS7110v-j&quot;
RefreshToken := &quot;1/SjYrJK9Ja2N57TxxIdoxvMTrrj2vDReeFK7yMOTLgA6fLsJp&quot;

; дальше не изменяем
Request := &quot;refresh_token=&quot; RefreshToken &quot;&amp;client_id=&quot; ClientId &quot;&amp;client_secret=&quot; ClientSecret &quot;&amp;grant_type=refresh_token&quot;
WinHTTP := ComObjCreate(&quot;WinHTTP.WinHTTPRequest.5.1&quot;)
WinHTTP.Open(&quot;POST&quot;, &quot;https://accounts.google.com/o/oauth2/token&quot;, true)
WinHTTP.SetRequestHeader(&quot;Content-Type&quot;, &quot;application/x-www-form-urlencoded&quot;)
WinHTTP.Send(Request)
WinHTTP.WaitForResponse()
msgbox % clipboard := WinHTTP.ResponseText</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2019-02-13T23:52:08Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=132178#p132178</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Google OAuth 2.0 и YouTube API]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=132160#p132160" />
			<content type="html"><![CDATA[<p>Тема для обсуждения &quot;Google OAuth 2.0 и YouTube API&quot;.<br /><a href="http://forum.script-coding.com/viewtopic.php?id=17647">http://forum.script-coding.com/viewtopic.php?id=17647</a></p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2019-02-12T17:24:34Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=132160#p132160</id>
		</entry>
</feed>
