Performing Google Federated Login/oAuth2 after initial Authentication

前端 未结 4 1981
你的背包
你的背包 2021-01-04 05:36

I am trying to support \"Hybrid\" Federated Login and oAuth2 (using logic from this document) for a webservice which will:

  1. support Sign in using your G
相关标签:
4条回答
  • 2021-01-04 06:09

    Add this paramter to the https://accounts.google.com/o/oauth2/auth URL call: approval_prompt=force and then the Sign in using your Google account will always show regardless of whether the user was already signed into that or any other account.

    So the call would be like this https://accounts.google.com/o/oauth2/auth?client_id=<client id>&redirect_uri=<uri>&scope=<scope>&access_type=<online or offline>&response_type=code&approval_prompt=force

    0 讨论(0)
  • 2021-01-04 06:14

    When the user is redirected back, you call the second request from your own (server-side?) code, and get their email address. When you successfully get it, that means that the user is logged on. You can add it to the session (e.g. as cookie), and as long as you have it, the user is logged on. You make the user log out by forgetting the email address, so by clearing the session/cookies.

    0 讨论(0)
  • 2021-01-04 06:15

    If your site has access to something like your Contacts or Analytics using OAuth, you'll never see "Sign in using your Google account". I'm pretty sure that's only if you use OpenID (not OAuth) only for sign-in.

    Specifically, OAuth is used for giving you access to APIs to create/update/delete data, while OpenID is for signing in.

    0 讨论(0)
  • 2021-01-04 06:16

    If you are asking how to identify user for future logins, you have two options:

    • Mix OAuth with OpenID, that is called Hybrid. I have described it on this answer.

    • Use userinfo scope and request userinfo (email, etc.) after successful OAuth authorization. It is described on Google OAuth 2 documentation.

    If you mean automatically login to your web site in future visits you can use OpenID "immediate mode" (openid.mode parameter).

    0 讨论(0)
提交回复
热议问题