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
FAQs | Eagle Aruba Resort
Why do Realtors not Want Buyers and Sellers to Meet? - HAR.com
Aberration Surface Entrances
Hotels Near 625 Smith Avenue Nashville Tn 37203
Big Spring Skip The Games
O'reilly's In Monroe Georgia
Rochester Ny Missed Connections
Bme Flowchart Psu
Love Compatibility Test / Calculator by Horoscope | MyAstrology
How to watch free movies online
Slag bij Plataeae tussen de Grieken en de Perzen
Scholarships | New Mexico State University
Les Rainwater Auto Sales
Carolina Aguilar Facebook
Missed Connections Dayton Ohio
Fraction Button On Ti-84 Plus Ce
Craigslist Portland Oregon Motorcycles
How to Create Your Very Own Crossword Puzzle
Jalapeno Grill Ponca City Menu
Scotchlas Funeral Home Obituaries
Evil Dead Rise - Everything You Need To Know
Crawlers List Chicago
Robert Deshawn Swonger Net Worth
Reptile Expo Fayetteville Nc
Discord Nuker Bot Invite
Milwaukee Nickname Crossword Clue
Lacey Costco Gas Price
Weather October 15
Helloid Worthington Login
Hoofdletters voor God in de NBV21 - Bijbelblog
Storelink Afs
1400 Kg To Lb
Great Clips On Alameda
Acadis Portal Missouri
Frank 26 Forum
When His Eyes Opened Chapter 2048
Cdcs Rochester
Cal Poly 2027 College Confidential
Sas Majors
Ucsc Sip 2023 College Confidential
Panolian Batesville Ms Obituaries 2022
Po Box 101584 Nashville Tn
Amy Zais Obituary
Zadruga Elita 7 Live - Zadruga Elita 8 Uživo HD Emitirani Sat Putem Interneta
Pelican Denville Nj
BYU Football: Instant Observations From Blowout Win At Wyoming
Syrie Funeral Home Obituary
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.