简体   繁体   中英

Google+ API - Cannot Sign-In - App not registered

I'm trying to log in trough Google+ API but when the login popups open I get

"Android App Not Registered, registering trough Google Console will hide this message"

Now I did register my app and I got an API key and added it to my manifest file

<meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="xxxxxxxxxxxxxxxxxxxxxxxxxx-xxxxx"/>

Then I configured the API Client like this :

gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestEmail()
            .requestScopes(new Scope(Scopes.PLUS_LOGIN), new Scope(Scopes.PLUS_ME))
            .build();

    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this, manager)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .addApi(Plus.API)
            .build();

EDIT: I also created the google-services.json file and put it inside app/ folder in the project. It logs me in correctly because I can see the username, email and other information but my app isn't shown between the authorized apps in my account.

What am I doing wrong??

Thanks for your help!!

EDIT - SOLVED :

I was using

.requestEmail()

in the GoogleSignInOptions, while I had to replace it with

.requestIdToken([oAuth2 Token])

Now the app gets correctly connected with the Google Console and I'm not getting the "App not registered" error anymore!

For anyone else having this problem, check the GoogleSignInOptions. You should request the token obtained when registering the oAuth2 credentials

gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
        .requestIdToken([oAuth2 Token])
        .requestScopes(new Scope(Scopes.PLUS_LOGIN), new Scope(Scopes.PLUS_ME))
        .build();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM