获得访问令牌来自谷歌Android的加 [英] Get access token from google plus Android
问题描述
谁能告诉我我究竟做错了什么?我需要从谷歌加访问令牌。
Can anyone tell me what am I doing wrong? I need to get the access token from Google Plus..
我把这个在我的 onConnected()
方法,但我没有收到访问令牌,而是我得到错误...
I put this in my onConnected()
method but I am not getting the access token, instead I am getting error...
code:
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();
}
错误:
08-07 10:10:24.199: E/GoogleAuthUtil(17203): Calling this from your main thread can lead to deadlock and/or ANRs
谁能告诉我什么是正确的方式来获得用户的谷歌加访问令牌?
Can anyone tell me what would be the correct way to get the Google Plus access token from the user?
推荐答案
您需要把请求在后台线程的令牌。我已经发布了一些例如code,展示了如何做,在这个问题:
You need to put the request for a token in a background thread. I've posted some example code showing how to do it in this question:
<一个href="http://stackoverflow.com/questions/17547019/calling-this-from-your-main-thread-can-lead-to-deadlock-and-or-anrs-while-getti/17547891#17547891">"Calling这从你的主线程可能导致死锁和/或ANRS同时获得accesToken&QUOT;从GoogleAuthUtil(谷歌加集成在Android中)
这篇关于获得访问令牌来自谷歌Android的加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!