【发布时间】:2013-12-04 18:02:36
【问题描述】:
我有一个应用程序,我正在尝试在其中获取 google 身份验证令牌。它在每个请求上都会超时,并且在 logcat 中没有给出任何有用的消息。我试图弄清楚我是否未能正确设置我的云控制台,或者我的代码是否有问题。
我的令牌请求类:
public class GetMyToken extends AsyncTask<String,Void,String>{
Context c;
String TAG = "wnycmap issues";
public GetMyToken(Context c) {
this.c=c;
}
@Override
protected String doInBackground(String...mEmail) {
String mScope = "oauth2:https://www.googleapis.com/auth/plus.me";
String email = mEmail[0];
System.out.println(c+email+mScope);
try {
return GoogleAuthUtil.getToken(c, email, mScope);
// System.out.println(token);
} catch (IOException transientEx) {
// Network or server error, try later
Log.e(TAG, transientEx.toString());
} catch (UserRecoverableAuthException e) {
// Recover (with e.getIntent())
Log.e(TAG, e.toString());
// Intent recover = e.getIntent();
//startActivityForResult(recover, REQUEST_CODE_TOKEN_AUTH);
} catch (GoogleAuthException authEx) {
Log.e(TAG, authEx.toString());
}
return "nope";
}
我调用它的方法:
private void authenticate() {
String accountEmail="asdf";
String token = "null";
AccountManager am = AccountManager.get(context);
Account[] accounts = am.getAccountsByType("com.google");
if (accounts != null){
Account account = accounts[0];
accountEmail = account.name;
System.out.println(context);
try {
token=new GetMyToken(getApplicationContext()).execute(accountEmail).get();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ExecutionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
还有我的相关清单设置
我会发布我的 logcat,但我得到的只是 println 告诉我我正在使用的上下文、电子邮件和范围,然后是一个错误,告诉我我的活动已超时。我没有收到任何回复。感谢您的任何回复,我已经不间断地研究了 5 天,并且正在竭尽全力试图解决这个问题。我知道它必须是简单的。我会接受任何想法。
【问题讨论】:
-
我的项目中确实有多个应用程序具有不同的包名称和相同的调试密钥。这是我问题的根源吗?
-
包名和sha键不是我问题的根源。我仍然不确定是什么。
标签: android google-app-engine authentication oauth