在使用 Firebase 进行 oauth 后无法点击 Google 加 api

Can't hit Google plus api after oauth with Firebase

2 小时试图让它工作,但我做不到。 Firebase 可以很好地验证用户身份,但它无法从 Google Plus API 中获取任何内容。 您将得到的错误:

{
    domain: "global"
    location: "Authorization"
    locationType: "header"
    message: "Invalid Credentials"
    reason: "authError"

}

代码是这样的:

    Auth.$authWithOAuthPopup(provider, {
      scope: ['profile', 'email']
    }).then(function(authData) {

          console.log(authData.token);
          gapi.client.setApiKey('<APIKEY>');
          gapi.client.load('plus','v1', function(){
            var request = gapi.client.plus.people.get({
              'userId': 'me'
            });
            request.execute(function(resp) {
              console.log('Retrieved profile for:' + resp.displayName);
              debugger;
            });
          });

    }, showError);

这一定与 Firebase 代表我们进行调用有关。因为我们在其中进行自己的身份验证的代码笔工作正常: http://codepen.io/morgs32/pen/KVgzBw

不要忘记在codepen中设置clientId和apiKey。

如果你能解决这个问题,你就会在圣诞节获得金币。

您正在尝试使用 authData.token 访问 Google。但是 authData.token 是用于访问 Firebase 的 JWT 令牌。

要访问 Google,您应该使用 authData.google.accessToken

另请参阅 Firebase documentation on using the Google provider 中的此页面。