如何整合为Android回送第三方登录 [英] How integrate loopback third-party login for android

查看:227
本文介绍了如何整合为Android回送第三方登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目包括Web和Android客户端。我想谷歌跨平台登录结合,回送第三方登录。

My project includes web and android client. I want to combine Google cross platform sign-in and loopback third-party login.

在我的方案,我绝不会要求用户名和密码。用户只使用谷歌的登录按钮,Web和Android应用程序上认证和授权。

In my scenario, I will never ask username and password. User only uses Google sign-in button for authentication and authorization on both web and android app.

让我们假设,这是你第一次与谷歌登录登录通过我的网站。在回送第三方的情况下,如果你不是在现有的数据库,它创建了一个账户对应提供商和外部标识。 (在这种情况下,提供者是谷歌和外部ID是你独特的谷歌ID)。这是一个网络,回环,例如护照

Lets assume, it's the first time you logged in with Google sign-in through my web site. In loopback third-party scenario, if you are not existing on db, it creates an account corresponded provider and external id. (In this case provider is google and external id is your unique google id). This is for web, loopback-example-passport

因此​​,假定为Android上面的场景。您单击只有谷歌签到按钮,然后回送服务器将能够做到上面的东西(如网络)

So, assume that above scenario for android. You click only Google Sign-in button and then loopback server will able to do above things (as web)

是否有回送这个内置的方式吗?如果不是这样,我怎么能这种情况在回环正确地集​​成?

Is there a built-in way in loopback for this? If not, how can I integrate this scenario in loopback properly?

推荐答案

那么这是一个有点老问题,但我已经遇到了在Android同样的问题,但与Facebook的第三方登录。

Well it's a little bit old question, but I've encountered the same issue on android, but with facebook third party login.

我没有找到任何微不足道的解决方案,所以经过大量的奋斗尝试不同的方法:(更改Facebook的谷歌的你的情况

I didn't find any trivial solution, so after a lot of struggle tried different approach: (change facebook to google for your case)


  1. UI用户presses的登录与Facebook按钮(被Facebook SDK为Android提供)

  2. 在与Facebook凭据UI用户登录

  3. 客户端获取来自Facebook用户的访问令牌

  4. 客户端侧加密访问令牌,并将其传递给服务器。

  5. 如果需要的话,获取有关请求的用户附加信息来验证令牌,和 -
  6. 服务器解密的访问令牌,并使用访问令牌与Facebook图形API会谈。
  7. 假设它是有效的,服务器检查的,如果用户已经拥有本地户口(可以用电子邮件或ID检查):

  1. UI user presses 'login with facebook' button (provided by facebook sdk for android)
  2. UI User signs in with facebook credentials
  3. Client side gets user's access token from facebook
  4. Client side encrypts the access token and passes it to the server.
  5. Server decrypts the access token, and talks with facebook graph API using access token - for validating the token, and if needed, for getting additional info related to requesting user.
  6. Assuming it's valid, server check's if the user already has local account (can be checked with email or id):

6.1。如果用户没有帐户,我们创建了一个新的使用Facebook的用户ID或电子邮件(环回需要因此,可以提供一个随机密码),这将赋予我们独特的用户ID,并发出我们的身份验证票( user.createAccessToken(TTL,回调))。

6.1 If user doesn't have an account, we create a new one with the Facebook User ID or email (loopback requires password so a random one can be provided), this will assign our own unique UserID and issue our auth ticket (user.createAccessToken(ttl, callback)).

6.2一样,继续只是本次会议

6.2 else, continue just with assigning auth ticket to user for this session

这篇关于如何整合为Android回送第三方登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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