Java 解码GoogleAuthUtil.getToken(Android)
在我的代码中,我获取的google+id令牌如下:Java 解码GoogleAuthUtil.getToken(Android),java,android,google-play-services,token,decode,Java,Android,Google Play Services,Token,Decode,在我的代码中,我获取的google+id令牌如下: Bundle bundle = new Bundle(); bundle.putString(GoogleAuthUtil.KEY_REQUEST_ACTIONS, "http://schemas.google.com/AddActivity http://schemas.google.com/BuyActivity");
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);
它返回一个76个字符的序列,而我应该接收如下内容:
{
'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
}
还返回此错误消息:
{
"error_description": "Invalid Value"
}
你知道我做错了什么吗?
我必须解码吗?如果是这样的话,如何解释?76个字符表示它是Base64密钥,这是您将其解码为字节数组的方式(如回答所示):
byte[]data=Base64.decode(Base64,Base64.DEFAULT);
字符串文本=新字符串(数据,“UTF-8”)代码>