Google登录因youtube帐户失败

时间:2015-12-29 09:01:19

标签: javascript oauth-2.0 google-api youtube-api google-authentication

我有一个使用Google登录的应用程序来获取YouTube频道的信息(上传视频,订阅等...)。当用户尝试登录时,如果用户有多个,则可以从Youtube频道列表中选择Google帐户列表。但是,当选择YouTube频道时,API会失败。

var login = function(options) {

if (!gapi.auth2){ // Retrieve the singleton for the GoogleAuth library and set up the client. gapi.load('auth2', function(){ gapi.auth2.init({ client_id: config.credentials.googleApiClientId, cookiepolicy: 'single_host_origin', scope: 'https://www.googleapis.com/auth/youtube.readonly' }); }); } var GoogleAuth = gapi.auth2.getAuthInstance(); return GoogleAuth.signIn(options); };

在回调JavaScript中,Google API说:

  

对象{类型:" tokenFailed",idpId:" google",错误:" USER_LOGGED_OUT"}

1 个答案:

答案 0 :(得分:0)

遇到类似的问题,经过一段时间的实验,我得到了这个工作,我不完全确定我所改变的问题是在prompt: 'select_account'呼叫选项中添加signIn和{ {1}} fetch_basic_profile: false来电选项:

这里是jsbin that might work for you,请务必将自己的client_id添加到init调用中,并确保将output.jsbin.com域列入白名单并从该域中预览jsbin。

init