OAuth Grant Types (Authorization Code Grant) (2024)

The authorization code grant type is used to obtain both access tokens and refresh tokens.

The grant type uses the additional authorization endpoint to let the authorization server interact with the resource owner in order to get consent for resource access.

Since this is a redirect-based flow, the client must be capable of initiating the flow with the resource owner's user agent (typically a web browser) and capable of being redirected back to from the authorization server.

OAuth Grant Types (Authorization Code Grant) (1)

The Authorization Code grant type is used by confidential and public clients to exchange an authorization code for an access token.

After the user returns to the client via the redirect URL, the application will get the authorization code from the URL and use it to request an access token.

The Authorization Code grant type is used by web and mobile apps. It differs from most of the other grant types by first requiring the app launch a browser to begin the flow. At a high level, the flow has the following steps:

  • The application opens a browser to send the user to the OAuth server
  • The user sees the authorization prompt and approves the app’s request
  • The user is redirected back to the application with an authorization code in the query string
  • The application exchanges the authorization code for an access token

The flow illustrated inFigure 3includes the following steps:

(1) The client initiates the flow by directing the resource owner's user agent to the authorization endpoint. The client includes its client identifier, code challenge (derived from a generated code verifier), optional requested scope, optional local state, and a redirect URI to which the authorization server will send the user agent back once access is granted (or denied).

(2) The authorization server authenticates the resource owner (via the user agent) and establishes whether the resource owner grants or denies the client's access request.

(3) Assuming the resource owner grants access, the authorization server redirects the user agent back to the client using the redirect URI provided earlier (in the request or during client registration). The redirect URI includes an authorization code and any local state provided by the client earlier.

(4) The client requests an access token from the authorization server's token endpoint by including the authorization code received in the previous step, and including its code verifier. When making the request, the client authenticates with the authorization server if it can. The client includes the redirect URI used to obtain the authorization code for verification.

(5) The authorization server authenticates the client when possible, validates the authorization code, validates the code verifier, and ensures that the redirect URI received matches the URI used to redirect the client in step (3). If valid, the authorization server responds back with an access token and, optionally, a refresh token.

The Authorization Code flow is best used in web and mobile apps. Since the Authorization Code grant has the extra step of exchanging the authorization code for the access token, it provides an additional layer of security not present in the Implicit grant type.

If you’re using the Authorization Code flow in a mobile app, or any other type of application that can’t store a client secret, then you should also use thePKCE extension, which provides protections against other attacks where the authorization code may be intercepted.

The code exchange step ensures that an attacker isn’t able to intercept the access token, since the access token is always sent via a secure backchannel between the application and the OAuth server.

OAuth Grant Types (Authorization Code Grant) (2024)
Top Articles
Equilar | Associated Press CEO Pay Study
Windows Basics: Keyboard Shortcuts in Windows
Use Copilot in Microsoft Teams meetings
Exclusive: Baby Alien Fan Bus Leaked - Get the Inside Scoop! - Nick Lachey
Wizard Build Season 28
St Als Elm Clinic
Call Follower Osrs
Pike County Buy Sale And Trade
Weather Annapolis 10 Day
Southland Goldendoodles
Discover Westchester's Top Towns — And What Makes Them So Unique
Cooking Fever Wiki
Mineral Wells Independent School District
Mbta Commuter Rail Lowell Line Schedule
Craigslist In Visalia California
Unity - Manual: Scene view navigation
Jang Urdu Today
Promiseb Discontinued
Hood County Buy Sell And Trade
The Many Faces of the Craigslist Killer
Costco Gas Hours St Cloud Mn
Ontdek Pearson support voor digitaal testen en scoren
15 Primewire Alternatives for Viewing Free Streams (2024)
Workshops - Canadian Dam Association (CDA-ACB)
Timeline of the September 11 Attacks
Harrison County Wv Arrests This Week
Vera Bradley Factory Outlet Sunbury Products
1636 Pokemon Fire Red U Squirrels Download
Possum Exam Fallout 76
How To Improve Your Pilates C-Curve
R/Mp5
Ff14 Sage Stat Priority
Duke Energy Anderson Operations Center
Maybe Meant To Be Chapter 43
Levothyroxine Ati Template
How much does Painttool SAI costs?
Skip The Games Grand Rapids Mi
Dee Dee Blanchard Crime Scene Photos
Wasmo Link Telegram
Carteret County Busted Paper
At Home Hourly Pay
Craigslist Minneapolis Com
Craigslist Rooms For Rent In San Fernando Valley
Makes A Successful Catch Maybe Crossword Clue
Swsnj Warehousing Inc
Dying Light Mother's Day Roof
Plumfund Reviews
Online College Scholarships | Strayer University
Sml Wikia
Gameplay Clarkston
Duffield Regional Jail Mugshots 2023
Latest Posts
Article information

Author: Kieth Sipes

Last Updated:

Views: 5841

Rating: 4.7 / 5 (47 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Kieth Sipes

Birthday: 2001-04-14

Address: Suite 492 62479 Champlin Loop, South Catrice, MS 57271

Phone: +9663362133320

Job: District Sales Analyst

Hobby: Digital arts, Dance, Ghost hunting, Worldbuilding, Kayaking, Table tennis, 3D printing

Introduction: My name is Kieth Sipes, I am a zany, rich, courageous, powerful, faithful, jolly, excited person who loves writing and wants to share my knowledge and understanding with you.