您好我使用最新的谷歌API获取null访问令牌我不知道我做错了什么。请帮忙..
Token=GoogleAuthUtil.getToken( MainActivity.this, mGoogleApiClient.getAccountName(), "oauth2:" + SCOPES)
此处的令牌为空..
这是代码
GoogleAuthUtil.getToken( MainActivity.this, mGoogleApiClient.getAccountName(), "oauth2:" + SCOPES);
E/RetrieveAccessToken: Unknown
private class RetrieveTokenTask extends AsyncTask<String, Void, String> {
@Override
protected String doInBackground(String... params) {
String accountName = params[0];
String scopes = "oauth2:https://www.googleapis.com/auth/plus.login";
try {
token = GoogleAuthUtil.getToken(getApplicationContext(), accountName,scopes);
// Log.e("token",token);
// Toast.makeText(getApplicationContext(),"token "+token,Toast.LENGTH_LONG).show();
} catch (IOException e) {
Log.e(TAG, e.getMessage());
} catch (UserRecoverableAuthException e) {
startActivityForResult(e.getIntent(), REQUEST_CODE_PICK_ACCOUNT);
} catch (GoogleAuthException e) {
Log.e(TAG, e.getMessage());
}
return token;
}
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
// Toast.makeText(getApplicationContext(),"token "+token,Toast.LENGTH_SHORT).show();
// Log.w("token",token);
Intent google_intent=new Intent(Login2.this,MainActivity.class);
startActivity(google_intent);
}
}
此外,我获取了帐户名称,但为什么不是访问令牌?