我可以使用谷歌加登录验证的应用程序引擎我OAuth的方法呢? [英] Can I use Google Plus sign in to authenticate my OAuth methods in app engine?

查看:127
本文介绍了我可以使用谷歌加登录验证的应用程序引擎我OAuth的方法呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我成功地实施了谷歌帐户登录这里使用教程Android的:

I successfully implemented Google Account sign in using the tutorial here for Android:

<一个href=\"https://developers.google.com/appengine/docs/java/endpoints/getstarted/clients/android/add_auth_$c$c\" rel=\"nofollow\">https://developers.google.com/appengine/docs/java/endpoints/getstarted/clients/android/add_auth_$c$c

这让我的应用程序成功地使用终端的应用程序引擎,同时验证。

This allows my app to successfully use endpoints in app engine while authenticated.

不过,现在我想执行一些谷歌加的功能,即:获取有关用户的一些信息。我跟着code进行登录如下G +:

However now I'd like to perform some Google Plus functionality, ie: obtain some info about the user. I followed the code for the G+ signin as below:

<一个href=\"https://developers.google.com/+/mobile/android/getting-started#step_4_initialize_the_googleapiclient\" rel=\"nofollow\">https://developers.google.com/+/mobile/android/getting-started#step_4_initialize_the_googleapiclient

我想知道的是,如果这2种方法能以某种方式进行合并?我觉得我要求用户用他的谷歌帐户登录,两次......反正有G +的GoogleApiClient可以用来生成所需谷歌端点认证凭据?

What I'd like to know is if these 2 methods can somehow be merged? I feel like I'm asking the user to sign in twice with his Google account... Is there anyway the GoogleApiClient of G+ can be used to generate the credentials needed for the Google Endpoints authentication?

推荐答案

在使用Google+签约,你几乎好去谈谈你的后端API。像这样的东西是我所做的:

Once signed in using Google+, you're almost good to go to talk to your Backend API. Something like this was what I did:

   @Override
   public void onConnected(Bundle bundle) {

    // Update the user interface to reflect that the user is signed in.
    mSignInProgress = STATE_DEFAULT;

    if (BuildConfig.DEBUG) {
        Log.i(LOG_TAG, "Signed in");
    }
    final String accountName = Plus.AccountApi.getAccountName(mGoogleApiClient);
    credential.setSelectedAccountName(accountName); // private GoogleAccountCredential credential;


    // call your GAE stuff


    }

这篇关于我可以使用谷歌加登录验证的应用程序引擎我OAuth的方法呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆