问题描述
我有一个 Google 的付费开发者帐户。我已验证我的 People API 已启用,并且我使用的是正确的 API 密钥和客户端 ID。当我尝试 Google 登录开始时,我在控制台中收到此错误,原因是 reason.result.error...
{
code: 401,message: "The request does not have valid authentication credentials.",status: "UNAUTHENTICATED"
}
我验证了 API 密钥和 ClientID 是正确的。我从这样的登录按钮方法开始......
didClickGoogleLogin = () => {
// 1. Load the JavaScript client library.
gapi.load('client',this.googleLoginStart);
}
googleLoginStart = () => {
// 2. Initialize the JavaScript client library.
gapi.client.init({
'apiKey': <API KEY HERE>,// clientId and scope are optional if auth is not required.
'clientId': <CLIENT ID HERE>,'scope': 'profile',}).then(function() {
// 3. Initialize and make the API request.
return gapi.client.request({
'path': 'https://people.googleapis.com/v1/people/me?personFields=Metadata,names,emailAddresses',})
}).then((response) => {
console.log(response.result);
const googleID = response.result.Metadata.sources[0].id;
const googleEmail = response.result.emailAddresses[0].value;
this.updateUser(googleID,googleEmail);
},function(reason) {
console.log("reason: ",reason);
});
}
这在我几个月前编写的另一个网络应用程序中对我有用,但现在也不起作用。
知道为什么在启用 API、API 密钥和客户端 ID 正确时我会收到无效凭据错误吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)