世博会,Firebase,用谷歌登录 [英] Expo, Firebase, Login with google
问题描述
在我的 React Native Expo 应用程序中,我想使用 google 帐户对用户进行身份验证.所以我遵循了 Expo Google首先使用 google 进行正常登录,这可以正常工作,然后使用 idToken
和 accessToken
向 firebase 进行身份验证.
in my React Native Expo application, I want to authenticate the user with google account. so I followed the Expo Googlefor a normal sign in with google first, Which was working, then using the idToken
and accessToken
to authenticate with firebase.
signInWithGoogleAsync = async () => {
try {
const result = await Google.logInAsync({androidClientId: ***, iosClientId: ***, scopes: ["profile", "email"] });
if (result.type === "success") { // I get result object
const credential = firebase.auth.GoogleAuthProvider.credential( result.idToken, result.accessToken);
/* credential is and xf {} object */
firebase.auth().signInWithCredential(credential)
.then(user => {console.log( user);})
.catch(error => {console.log(error);});
return result.accessToken;
}
return { cancelled: true };
} catch (e) {
return { error: true };
}
};
但我收到以下错误:
[Error: {"error":{"errors":[{"domain":"global","reason":"invalid","message":"Invalid Idp Response: the Google id_token is not allowed to be used with this application. Its audience (OAuth 2.0 client ID) is 268165840544-097g31a3qhd0mm.apps.googleusercontent.com, which is not authorized to be used in the project with project_number: 747269174."}],"code":400,"message":"Invalid Idp Response: the Google id_token is not allowed to be used with this application. Its audience (OAuth 2.0 client ID) is 26816581eun236bp9vdb7b6r.apps.googleusercontent.com, which is not authorized to be used in the project with project_number: 747269174."}}]
推荐答案
在错误消息中添加 url => 例如.您的案例 = 268165840544-097g31a3qhd0mm.apps.googleusercontent.com
Add url in error message => eg. your case = 268165840544-097g31a3qhd0mm.apps.googleusercontent.com
下
认证>登录方式>谷歌
将来自外部项目的客户端 ID 列入白名单(可选)
在 Firebase 上
Whitelist client IDs from external projects (optional)
on Firebase
这篇关于世博会,Firebase,用谷歌登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!