A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.okta.com/authentication-guide/implementing-authentication/auth-code-pkce/ below:

Implement authorization by grant type

Before you can implement authorization, you need to register your app in Okta by creating an app integration from the Admin Console.

The following sections outline the main components required to implement the Authorization Code with PKCE flow using direct calls to the OIDC & OAuth 2.0 API (opens new window). Typically, you don't need to make direct calls if you're using one of the Okta SDKs.

Create the Proof Key for Code Exchange

Similar to the standard Authorization Code flow, your app starts by redirecting the user's browser to your authorization server's /authorize endpoint. However, in this instance you also have to pass along a code challenge.

Your first step is to add code to your app that generates a code verifier and challenge:

The PKCE generator code returns both values as JSON:

The code_challenge is a Base64-encoded SHA256 hash of the code_verifier. Your app saves the code_verifier for later, and sends the code_challenge along with the authorization request to your authorization server's /authorize URL.

Request an authorization code

If you're using the org authorization server, then your request URL would look something like this:

Note the parameters that are being passed:

See the OAuth 2.0 API reference (opens new window) for more information on these parameters.

If the user doesn't have an existing session, this request opens the Okta sign-in page. If they have an existing session, or after they authenticate, the user arrives at the specified redirect_uri along with an authorization code:

This code can only be used once, and remains valid for 300 seconds, during which time it can be exchanged for tokens.

Exchange the code for tokens

To exchange the authorization code for access and ID tokens, you pass it to your authorization server's /token endpoint along with the code_verifier that was generated at the beginning:

Important: Unlike the regular Authorization Code flow, this call doesn't require the HTTP Authorization header with the client ID and secret. That is why this version of the Authorization Code flow is appropriate for mobile apps.

Note the parameters that are being passed:

See the OIDC & OAuth 2.0 API reference (opens new window) for more information on these parameters.

If the code is still valid, and the code verifier matches, your application receives back access and ID tokens:

Validate access token

When your application passes a request with an access token, the resource server needs to validate it. See Validate access tokens.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4