2

In my code im fetching google+ id token like this :

Bundle bundle = new Bundle();
                    bundle.putString(GoogleAuthUtil.KEY_REQUEST_ACTIONS,
                            "http://schemas.google.com/AddActivity http://schemas.google.com/BuyActivity");
                    String token = GoogleAuthUtil.getToken(context,
                          Plus.AccountApi.getAccountName(mGoogleApiClient), scope,bundle);

Which returns a 76 character sequence while i should be receiving something like :

{
  'issued_to': 'xxxxxx.apps.googleusercontent.com',
  'user_id': 'yyyyyy',
  'expires_in': 3457,
  'access_type': 'online',
  'audience': 'xxxxxx.apps.googleusercontent.com',
  'scope': 'https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile',
  'email': 'xxxxx@yyyyy.com',
  'verified_email': True
}

Also https://www.googleapis.com/oauth2/v3/tokeninfo?id_token=xyz returns this error message:

{
 "error_description": "Invalid Value"
}

Any ideas what im doing wrong ? Do i have to decode it ? if so how ?

dxv
  • 31
  • 2

1 Answers1

0

76 character mean its a Base64 key and this is how you decode it to a byte array (as answered here):

byte[] data = Base64.decode(base64, Base64.DEFAULT);
String text = new String(data, "UTF-8");
Community
  • 1
  • 1
Kay_N
  • 987
  • 5
  • 12