使用谷歌账户在Android应用程序日志 [英] Using google-account to log in on Android Application

查看:203
本文介绍了使用谷歌账户在Android应用程序日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发在Android上的应用程序,我想允许用户与他们的谷歌帐户登录,有人可以帮助我PLZ?

I'm developing an application on Android and i want to allow users to log in with their google account , can someone help me plz?

推荐答案

您可能需要进行身份验证使用谷歌帐户中的一个已经在设备中配置像一些应用程序的用户这样做,对于按照下面的链接 -

You might want to authenticate the user using one of the google account already configured in your device like some of the apps do, for that follow the below link -

验证为OAuth2服务 - <一个href="http://developer.android.com/training/id-auth/authenticate.html">http://developer.android.com/training/id-auth/authenticate.html

"Authenticating to OAuth2 Services" - http://developer.android.com/training/id-auth/authenticate.html

这是谷歌 下载样本 - 安卓SDK管理器/其他/谷歌播放服务

Download Sample from Google - Android SDK Manager/Extras/Google Play Services

在简单的步骤,它确实

  1. 在显示的帐户列表中移动
  2. 在生成的访问令牌从所选的帐户
  3. 从获取访问令牌帐户名通过联系谷歌服务(单独调用),只是告诉大家,它已经通过身份验证。

这是另外一个环节是在解释过程中具有良好 - <一href="http://android-developers.blogspot.in/2013/01/verifying-back-end-calls-from-android.html">http://android-developers.blogspot.in/2013/01/verifying-back-end-calls-from-android.html

This is another link which is good in explaining the process - http://android-developers.blogspot.in/2013/01/verifying-back-end-calls-from-android.html

您可以按照下面的登录步骤,在您的应用程序

you can follow below steps for Login in your app

  1. 您将生成的访问令牌发送到后端服务器
  2. 访问令牌是否有效由这个网址<一接触谷歌的服务
  3. 在后端服务器检查href="https://www.googleapis.com/oauth2/v1/userinfo?access_token=ACCESS_TOKEN">https://www.googleapis.com/oauth2/v1/userinfo?access_token=ACCESS_TOKEN"
  4. 接下来后端服务器响应的应用程​​序是否使用户登录还是不行。
  1. you will send the generated access token to your Back-end server
  2. Back-end server checks that access token is valid or not by contacting google services by this url "https://www.googleapis.com/oauth2/v1/userinfo?access_token=ACCESS_TOKEN"
  3. Next Back-end server responds to app whether to make the user login or not.

以下是上面的响应格式为用户信息呼叫

Below is response format of above "userinfo" call

{
 "id": "ID",
 "name": "NAME",
 "given_name": "GiVEN NAME",
 "family_name": "FAMILY_NAME",
 "link": "https://plus.google.com/ID",
 "picture": "https://PHOTO.jpg",
 "gender": "GENDER",
 "locale": "LOCALE"
}

如果你想电子邮件ID 连同响应您必须修改

If you want Email id along with that response you have to modify

SCOPE =oauth2:<一href="https://www.googleapis.com/auth/userinfo.profile">https://www.googleapis.com/auth/userinfo.profile";

SCOPE = "oauth2:https://www.googleapis.com/auth/userinfo.profile";

SCOPE =oauth2:<一href="https://www.googleapis.com/auth/userinfo.profile">https://www.googleapis.com/auth/userinfo.profile <一href="https://www.googleapis.com/auth/userinfo.email">https://www.googleapis.com/auth/userinfo.email";

SCOPE = "oauth2:https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email";

这是样品中

这篇关于使用谷歌账户在Android应用程序日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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