Reputation: 38
I'm trying to authenticate with google in a Flutter Web project, and I have something like this
final GoogleSignIn _googleSignIn = GoogleSignIn(
scopes: <String>[
'email',
],
);
Future<void> test() async {
try {
await _googleSignIn.signOut();
GoogleSignInAccount? googleUser = await _googleSignIn.signIn();
} catch (e) {
print(e);
}
}
I'm just doing so and Google pop up appears, but when I select account I receive this response
{"access_token":"<redacted>","token_type"
:"Bearer","expires_in":3598,"scope":"email profile
https://www.googleapis.com/auth/userinfo.profile openid
https://www.googleapis.com/auth/userinfo.email","authuser":"0","prompt":"none"}
and this error
[GSI_LOGGER-TOKEN_CLIENT]: Trying to set gapi client token.
[GSI_LOGGER-TOKEN_CLIENT]: The OAuth token was not passed to gapi.client, since the
gapi.client library is not loaded in your page.
ClientException: {
"error": {
"code": 403,
"message": "People API has not been used in project proyectId before or it is
disabled. Enable it by visiting
https://console.developers.google.com/apis/api/people.googleapis.com/overview?
project=proyectId then retry. If you
enabled this API recently, wait a few minutes for the action to propagate to our
systems and retry.",
"status": "PERMISSION_DENIED",
"details": [
{
"@type": "type.googleapis.com/google.rpc.Help",
"links": [
{
"description": "Google developers console API activation",
"url":
"https://console.developers.google.com/apis/api/people.googleapis.com/overview?
project=proyectId"
}
]
},
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "SERVICE_DISABLED",
"domain": "googleapis.com",
"metadata": {
"service": "people.googleapis.com",
"consumer": "projects/proyectId"
}
}
]
}
}
I already added meta tag in index.html
<meta name="google-signin-client_id" content="googleProyectId" />
So i dont know if I'm missing something
Upvotes: 0
Views: 107
Reputation: 38
Reading the docs, i realize that in Flutter Web the signIn method should not be used and will be deprecated, it is better to use a mix of signInSilently method, but it sometimes fails if user closes it once and it doesn't open anymore (for security i guess).
Another way they recommend it's to use their renderButton, it works, but it's not customizable.
In my case, I'm using Firebase, so i did it this way
FirebaseAuth.instance.signInWithPopup(GoogleAuthProvider());
Of course i need to have previous firebase config.
However, i think that they should improve a real alternative for signIn()
Upvotes: 0