我正在尝试在我的项目中使用登录。我可以使用GoogleSignIn.signInAsync()登录,但是在返回的对象中,refreshToken、idToken和accessTokenExpirationDate都是空的。有人知道问题出在哪里吗?我使用Expo4.2.1。我已经退出了这个项目,并使用react原生运行-android运行它。
这是我的代码:
import React from 'react';
import { View, Button } from 'react-native';
import * as GoogleSignIn from 'expo-google-sign-in';
export default function App() {
return (
<View>
<Button title='sign in' onPress={async () => {
await GoogleSignIn.initAsync({
clientId: '<MY CLIENT ID>',
scopes: [
GoogleSignIn.SCOPES.OPEN_ID
],
});
const r = await GoogleSignIn.signInAsync();
console.log(JSON.stringify(r));
}}/>
</View>
);
}结果是这样的:
{
"type": "success",
"user": {
"uid": "8978924659847365874563486867",
"email": "john.bar@gmail.com",
"displayName": "John Bar",
"photoURL": "https://lh3.googleusercontent.com/a-/AjsgdyegdrR-_wluyiuBUUKDKWBUWYDKUWGHDjO-M",
"firstName": "John",
"lastName": "Bar",
"auth": {
"idToken": null,
"refreshToken": null,
"accessToken": "ya29.a0AfH6SMCh1K322dfdf34rff6_gGHW98-kIngxBUUTtfRZTugtwff4f4wf4f4wf4fPib9fc2JPXmg7ewfGx7peVtC4ffwfw4fwfw4fw4fBeFkqJydbWxcwiUb",
"accessTokenExpirationDate": null
},
"scopes": [
"https://www.googleapis.com/auth/userinfo.profile",
"https://www.googleapis.com/auth/userinfo.email"
],
"serverAuthCode": null
}}
奇怪的是,结果中的作用域字段不包含openid。
这些是我在谷歌云控制台中的凭据( SHA1指纹来自debug.keystore)。

同意设置


提前感谢
发布于 2021-11-21 00:41:44
尝试使用webClientId而不是clientId在initAsync中--它对我起了作用。
await GoogleSignIn.initAsync({
webClientId: '<MY CLIENT ID>',
});https://stackoverflow.com/questions/67081848
复制相似问题