How to use OAuth2 to implement third-party login / registration?

Here is my plan (authorization code stream) for implementing this login / registration logic. (a third party provided the OAuth2 API )

First, the SPA will send a GET request to a third-party

GET https://www.example.com/oauth2
client_id=dummyclient
redirect_uri=https://mysite/callback
response_type=code
scope=openid

Then, if the user agrees to give his openid mysite, then fronend will receive a 301 HTTP response.

---> 301 https://mysite/callback?code=dummycode

Then the browser will redirect the page to mysite/callback, and it will reload the SPA and display the code at a URL that can be captured by the SPA, after which it will send the code to a real callback.

GET https://mysite/api/real-callback?code=dummycode

, access_token. access_token, API, openid, , . , HTTP- SPA, access_token my OAuth2 401 .

, , , ( - client_id, OAuth2 . , . , access_token .) OAuth2 , ​​ .

+6
1

OAuth2 Implicit access_token, id_token (OpenID Connect). SPA , , , , . SPA .

,

  • SPA OAuth2 - (SPA ),
  • URI ,
  • SPA.

: OpenID Connect

id_token, access_token , , Introspection https://tools.ietf.org/html/rfc7662 ( username). username . OAuth2 (, ).

, OAuth2 client_id .

+1

All Articles