+ Build the authorization URL and redirect the user to the authorization server
+
+
+ After the user is redirected back to the client, verify the state matches
+
+
+ Exchange the authorization code for an access token
+
+
+
+
+
+
+
+
+
1. Build the Authorization URL
+
+
?
+ &
+ &
+ &
+ &
+ &
+
Let's break it down...
+
+
+
+
+
URL of the authorization endpoint on the server. How is this path constructed will
+ differ between OAuth providers (such as Keycloak or Okta). to
+ find out the proper URL, there always exists
+ /.well-known/openid-configuration endpoint that contains all the necessary
+ information.
+
+
+
+
response_type=
+
OAuth 2.0 response type. In this case, we are using the Authorization Code flow, so
+ we are requesting the authorization code.
+
+
+
client_id=
+
Client ID of the application. This is a public identifier for the client, and it is
+ used by the authorization server to identify the application
+ when redirecting the user back to the client.
+
+
+
redirect_uri=
+
Redirect URI of the client. This is the URL that the authorization server will
+ redirect the user back to after the user has logged in and
+ granted permissions. The redirect URI must match one of the URIs registered for the
+ client ID.
+
+
+
scope=
+
Scopes requested by the client. Scopes are used to limit the access of the access
+ token. In this case, we are requesting the offline_access scope,
+ which allows the client to obtain a refresh token.
+
+
+
state=
+
State parameter. This is an optional parameter that the client can use to maintain
+ state between the request and callback. The authorization
+ server includes this parameter when redirecting the user back to the client,
+ allowing the client to verify that the response is coming from the
+ server and not a malicious third party.
+ Build the authorization URL and redirect the user to the authorization server
+
+
+ After the user is redirected back to the client, verify the state matches
+
+
+ Exchange the authorization code for an access token
+
+
+
+
+
+
+
+
+
2. Verify the state parameter
+
+
You have now been redirected back to the application, to the page that was specified in the redirect-url parameter. In the URL you can notice, that there are addtional query parameters:
+
+
Let's break it down...
+
+
+
state=
+
This is the state parameter that was sent in the initial request. It is used to prevent CSRF attacks.
+
+
+
session_state=
+
Session state is a parameter that is used to maintain state between the request and callback. It is used to prevent CSRF attacks.
+
+
+
code=
+
This is the authorization code that will be exchanged for an access token.
+
+
+
+
Now we have everything necessary to obtain token for the user. But is the state we have sent equivalent to the one we received back?
Client ID of the application. This is a public identifier for the client, and it is
+ used by the authorization server to identify the application
+ when redirecting the user back to the client.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
- aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis
- aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
- occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
- aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
- Duis
- aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
- occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
+
Welcome to OAuth 2.0 Playground
+
This playground serves as an interactive platform designed to familiarize developers and students with the
+ intricacies of OAuth authentication processes. Beyond just theoretical knowledge, this playground provides practical
+ insights into the OAuth token exchange,
+ callback handling, and potential pitfalls or challenges one might face during real-world integrations. The ultimate aim
+ is to bolster
+ understanding and confidence in implementing OAuth, ensuring secure and efficient user authentication and authorization
+ in modern web applications.