![](/img/trans.png)
[英]Framework Error when Google SignIn Firebase by idToken Flutter
[英]React Native Google Signin idToken null
我正在使用 react-native 0.60.5,使用 firebase 身份验证(使用 package react-native-firebase 和 react-native-google-signin)。
一切对我来说都很好,谷歌标志返回 object 用户登录,但 idToken 始终是 null。我需要获取 idToken 才能在 firebase 中执行身份验证。
import { GoogleSignin } from 'react-native-google-signin';
export const googleLogin = async () => {
GoogleSignin.configure();
const userInfo = await GoogleSignin.signIn();
//here we have the issue. userInfo cotains all google user informations except the idToken
//userInfo.idToken is null
}
如何修复谷歌登录以返回 idToken?
添加在 Firebase authentication/signInmethod/Google 中可用的 Web 客户端 ID:
function configureGoogleSign() {
GoogleSignin.configure({
webClientId: WEB_CLIENT_ID,
offlineAccess: false
})
}
这对我有用。
您尚未指定 webclientId。
并确保在 useEffect 方法中配置 google 登录,以便在加载屏幕时它已经配置。
useEffect(() => {
GoogleSignin.configure({
webClientId:
'YOUR_WEBCLIENT_ID',
});
}, []);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.