世博会,Firebase,使用Google登录 [英] Expo, Firebase, Login with google
问题描述
在我的React Native Expo应用程序中,我想使用google帐户对用户进行身份验证.因此我遵循了通过Google Expo 进行正常登录,然后再使用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
在
身份验证>登录方法> Google
Authentication > Sign-in Method > Google
Whitelist client IDs from external projects (optional)
在Firebase上
Whitelist client IDs from external projects (optional)
on Firebase
这篇关于世博会,Firebase,使用Google登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!