我正在使用YouTube api v3,通过https://developers.google.com/youtube/v3/code_samples/php#retrieve_my_uploads中的示例检索视频列表
我打开页面,应用程序要求授权。我单击授权的链接,选择我的Gmail帐户,然后得到列表。
问题是,即使几秒钟后我又回到该应用程序,我都必须再次授权该应用程序。
我以为一旦授权该应用程序,您就可以将令牌交换为刷新令牌。
由于文档或在线对其进行的引用非常贫乏,因此在任何地方都可以显示一些代码以获取刷新令牌的代码。
我真的需要一些帮助,以使它正常工作,因为我已经尝试了过去几周,却一无所获。
从Google OAuth连接用户后,如果此用户希望在下一个需要选择其Google帐户的会话期间重新连接,则会再次询问该权限.
根据文档,负责授权请求的参数提示的行为如下:
如果未指定任何值且用户先前未授权访问,则会向用户显示同意屏幕.
因此,用户不必重新排序他的同意(通过验证,该申请存在于我的授权中).
设想的唯一答案是关于这个问题的答案:用谷歌登录总是要求用户同意
因为我也在没有安全HTTP的情况下在本地工作,但他认为存在cookie策略,但事实并非如此.
代码生成URL
/**
* Create a new OAuth2Client with the credentials previously loads
*/
private getOAuth2() : OAuth2Client {
return new OAuth2(
this.credentials.client_secret,
this.credentials.client_id,
this.credentials.redirect_uris[0]
);
}
/**
* Create connection URL for the given scopes
* @param scopes
*/
public url(scopes: Array<string>) : string {
return this.client.generateAuthUrl({
access_type: "offline",
scope: scopes
});
}
// The scope used to generate URL is 'https://www.googleapis.com/auth/youtube.readonly'
// this.client refer to a client …Run Code Online (Sandbox Code Playgroud)