我的代码:Android的谷歌帐户价值getauthtoken空
Account[] accts = mgr.getAccountsByType("com.google");
Account acct = accts[0];
System.out.println("account:" + acct);
AccountManagerFuture<Bundle> acc=mgr.getAuthToken(acct, OAUTH2_SCOPE, null, null,
null, null);
Bundle authTokenBundle = acc.getResult();
String authToken = authTokenBundle.get(AccountManager.KEY_AUTHTOKEN).toString();
System.out.println("authtoken:"+authToken);
代码工作每1天之后。身份验证令牌今天出现,但它不会在明天再来,并且在此后的一天再次运行。一个非常奇怪的问题。
我OAUTH2_SCOPE = "oauth2:https://www.googleapis.com/auth/userinfo.profile"
的getAuthToken()
函数返回空值。