I am trying to use Oauth2 to authenticate the google user logged in my device. I have created the client ID but I am not able to get the expected result.
Code is:
String mScope="oauth2:server:client_id:NNNNNNNNNNN.apps.googleusercontent.com:api_scope:https://www.googleapis.com/auth/plus.login";
protected Void doInBackground(String... accountName) {
Log.i("Inside on AsynTask:","I am here");
String accName=accountName[0];
try {
token1 = GoogleAuthUtil.getToken(Web_view_demo.this,
accName,
mScope);
Log.i("Inside on AsynTask:","I am here");
} catch (IOException transientEx) {
// Network or server error, try later
Log.e("IO", transientEx.toString());
} catch (UserRecoverableAuthException e) {
// Recover (with e.getIntent())
Log.e("UserRecover", e.toString());
//Intent recover = e.getIntent();
//startActivityForResult(recover, 1);
} catch (GoogleAuthException authEx) {
// The call is not ever expected to succeed
// assuming you have already verified that
// Google Play services is installed.
Log.e("GoogleAuth", authEx.toString());
}
Log.i("Token:",token1);
return null;
}
Error is:
com.google.android.gms.auth.GoogleAuthException: Unknown
Help much appreciated.
Thank you.
For me the below format of scope worked:
String mScope="oauth2:server:client_id:123456789-dgrgfdgfdgfdgngemhmtfko16f5tnobqphb6v.apps.googleusercontent.com:api_scope:https://www.googleapis.com/auth/plus.login"
Along with this if you are missing the Consent Screen set up in the Developers console for your app you might end up with this GoogleAuthException: Unknown.