OAuth and 3rd Party Login/User

Hello,

I’m trying to sign in via Google. I saw it in the SDK documentation and implemented it in Flutter.

PS. I have already looked at the How to setup OAuth2 Google in Parse but without success, because I can redeem the parameters through the GoogleSignIn package.

class OAuthLogin {
  final GoogleSignIn _googleSignIn = GoogleSignIn( scopes: ['email', 'https://www.googleapis.com/auth/contacts.readonly'] );
  
  signInGoogle() async {
    GoogleSignInAccount account = await _googleSignIn.signIn();
    GoogleSignInAuthentication authentication = await account.authentication;
    await ParseUser.loginWith(
        'google',
        google(_googleSignIn.currentUser.id, 
               authentication.accessToken, 
               authentication.idToken));
  }
}

Authentication with Google works perfectly I get the User ID on Google, the Access Token and the idToken perfectly, however when trying to log in to Parse the following error appears:

Do I need any further configuration with the Parse SDK Flutter?

To improve the explanation: When executing a CURL generated by the SDK Flutter, the following error will be returned.

{
    "code": 101,
    "error": "invalid signature"
}

What is the version of Parse Server that you are running? Could you share the configuration that you have in place for your parse server?

The version of Parse Server is 4.5.0, I will prepare the release of the ports to share access to the settings

@jjunin

am using authentication with a Flutter application with parse server 4.5.0.

After several searches, I solved the problem by adding “default_web_client_id” in strings.xml for Android.

This identifier I created at https://console.cloud.google.com/ creating an OAuth 2.0 client IDs for Android.

{
  "google": {
    "id": "1166077090183XXXXXXXX",
    "id_token": "eyJhbGciOiJSUzI1N.......",
    "access_token": "ya29..........."
  }
}

For login to work, it is necessary to inform the fields:

  • id_token
  • access_token

I was able to successfully authenticate!

Including “string.xml” in Android settings.

Thanks @RodrigoSMarques

1 Like