验证后端在Android上获取Google Token

时间:2015-07-02 01:28:29

标签: android google-api-client

当我尝试在Android中将Google令牌添加到Balidation后端时,我遇到了问题。我创建Web应用程序客户端ID(我在url路径中使用http://localhost),Android客户端ID,并使用此代码:

public class GoogleOAuthTask extends AsyncTask<Void, Void, String> {

private static final String TAG = GoogleOAuthTask.class.getSimpleName();
Activity mActivity;
String mEmail;

private final static String SCOPE = "audience:server:client_id:XXXXXXXXXXXXXXXXXXXAAAAAXXXXXXXXXXX.apps.googleusercontent.com";

public GoogleOAuthTask(Activity activity, String email) {
    this.mActivity = activity;
    this.mEmail = name;
}

@Override
protected String doInBackground(Void... params) {
    String accountName = "myRandomValidEmail@gmail.com";
    Account account = new Account(accountName, GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE);
    String scopes = "audience:server:client_id:XXXXXASASXXXXX.apps.googleusercontent.com"; // This is my Web Application Client Id
    try {
        return GoogleAuthUtil.getToken(mActivity, account, scopes);
    } catch (IOException e) {
        Log.e(TAG, "Error retrieving ID token.", e);
        return null;
    } catch (GoogleAuthException e) {
        Log.e(TAG, "Error retrieving ID token.", e);
        return null;
    }
}
}

我的问题是:

当我调用GoogleAuthUtil.getToken(mActivity,account,scopes)时,代码不会继续,即方法永远不会结束。

我在等待

更多信息:

我使用.android / debug.keystore来生成SHA-1哈希 我在Javascript Origins中使用http://localhost 我在重定向URI中使用http://localhost/MyWebService。 该行出现在logcat:

Could not find method android.app.Notification$Builder.setLocalOnly

0 个答案:

没有答案