Kar*_*lis 7 android google-plus
谁能告诉我我做错了什么?我需要从Google Plus获取访问令牌..
我把它放在我的onConnected()方法中,但我没有获得访问令牌,而是我收到错误...
码:
try {
String token = GoogleAuthUtil.getToken(this, mPlusClient.getAccountName() + "", "oauth2:" + Scopes.PLUS_PROFILE +
"https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email");
Log.d("AccessToken", token);
} catch (UserRecoverableAuthException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (GoogleAuthException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
错误:
08-07 10:10:24.199: E/GoogleAuthUtil(17203): Calling this from your main thread can lead to deadlock and/or ANRs
Run Code Online (Sandbox Code Playgroud)
谁能告诉我从用户那里获取Google Plus访问令牌的正确方法是什么?
您需要将令牌请求放在后台线程中.我已经发布了一些示例代码,展示了如何在这个问题中执行此操作:
"从主线程中调用此函数可能会导致从GoogleAuthUtil获取accessToken时出现死锁和/或ANR"(Google Plus中的Google Plus集成)
| 归档时间: |
|
| 查看次数: |
15663 次 |
| 最近记录: |