将访问令牌发送到我的服务器并验证它,Google +登录Android

时间:2014-06-05 18:09:41

标签: android validation google-plus access-token google-login

我已编写此代码以从Google获取访问令牌

现在我想将此访问令牌发送到我的服务器,然后我希望我的服务器将其发送给Google 验证令牌。

如果有人可以给我工作代码或详细解释如何执行此操作,我将感激不尽? 我正在将 Google+登录实施到我的 Android应用

@Override
public void onConnected(Bundle connectionHint) {

    Log.v(TAG, "Connected. Yay!");

    findViewById(R.id.sign_in_button).setVisibility(View.INVISIBLE);

    final Context context = this.getApplicationContext();
    AsyncTask task = new AsyncTask() {
     @Override
       protected Object doInBackground(Object... params) {
            String scope = "oauth2:" + Scopes.PLUS_LOGIN;
              try {

                        String token = GoogleAuthUtil.getToken(context,
                                mPlusClient.getAccountName(), scope);
                    } catch (UserRecoverableAuthException e) {

                        e.printStackTrace();
                    } catch (IOException e) {
                        e.printStackTrace();
                    } catch (GoogleAuthException e) {
                        e.printStackTrace();
                    }
                    return null;
                }
            };
            task.execute((Void) null);



}

0 个答案:

没有答案