gpt4 book ai didi

oauth - 使用 Firebase 进行 oauth 后无法访问 Google plus api

转载 作者:行者123 更新时间:2023-12-01 13:47:51 24 4
gpt4 key购买 nike

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

不要忘记在代码笔中设置 clientId 和 apiKey。

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

最佳答案

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

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

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

关于oauth - 使用 Firebase 进行 oauth 后无法访问 Google plus api,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34448497/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com