Issue
I have to login with google plus and firebase. I use the next code to get the login:
loginGoogle() {
this.googlePlus.login({})
.then((response) => {
const googleCredential = firebase.auth.GoogleAuthProvider.credential(response.accessToken);
firebase.auth().signInWithCredential(googleCredential)
.then(() => {
console.log("Firebase success: " + JSON.stringify(response))
}).catch((error) => {
console.log(error)
});
})
.catch((error) => {
console.error("Error: ", error)
});
}
But always returns next error:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "Unable to parse Google id_token: ya29.GltpBZ_0uSz2G...."
}
],
"code": 400,
"message": "Unable to parse Google id_token: yya29.GltpBZ_0uSz2G...."
}
I check the SHA1 and put in the firebase project android and create a google's project, but nothing fix my issue.
Solution
Try passing the webClientId options property to the googlePlus login method
As mentioned in google plus cordova docs you will need the Web-client Oauth 2.0 id here you can find this in your firebase console authentication-> signIn method -> click edit on google sign-in method there under web sdk you will find the web client id use that id in your googleplus login webClientId property.
if you want a new one you can create one like this:
You have to create Web-client Oauth 2.0 id here https://console.developers.google.com . After that you will have client id and secret Open https://console.firebase.google.com and goto Authentication -> Google -> Settings -> Web SDK and use clien od and secret you have got on the step 1.
this.googlePlus.login({
'webClientId': 'client id of the web app/server side', // optional clientId of your Web application from Credentials settings of your project - On Android, this MUST be included to get an idToken. On iOS, it is not required.
})
Answered By - Mahesh Jadhav
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.