Jin
Jin

Reputation: 1

Google OAuth2 throws GoogleAuthException in release but not in debug mode

I'm using the following scope to access Google Auth2 in Android. XXXXXX.apps.googleusercontent.com refers to the web application client id.

private static final String SCOPE = "oauth2:server:client_id:XXXXXX.apps.googleusercontent.com:api_scope:https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/plus.login";

The following line of code works in debug mode, but not in release mode. All parameters of the getToken method are the same in each mode.

String token = GoogleAuthUtil.getToken(mActivity, mEmail, mScope);

In release mode, it's giving me a GoogleAuthException with error 'Unknown'. I've searched everywhere, but I haven't found any satisfactory answer. In theory, shouldn't the piece of code work whether in debug mode or in release mode, since signatures are not involved?

UPDATE: I eventually figured out that I had to use the new Google+ Signin feature https://developers.google.com/+/mobile/android/sign-in

Upvotes: 0

Views: 398

Answers (1)

Nil
Nil

Reputation: 324

SHA1 key get by two way:

a) from debug keytool b) from release keytool

you need to change your sha1 key for making client id :

1) currently for debugging, you are using sha1 signature of your pc by debug keytool file

2) but now in release mode you need to use sha1 key from release keytool file

and release keytool you can get by sign you .apk file

Hope that this information you might be help you.

Upvotes: 1

Related Questions