๐ Master your Security+ skills with Pluralsight here: Pluralsight
Youโll learn what OAuth 2.0 is and how authorization codes, PKCE, scopes, and access tokens let apps access data without sharing your password. Understand authorization versus authentication and spot risky app permissions as you build your CompTIA Security+ foundation.
Chapters: 0:00 Intro 0:13 What problem does OAuth 2.0 solve? 0:44 Who are the four participants in OAuth? 1:17 How does the OAuth authorization code flow work? 2:48 Is OAuth authentication or single sign-on? 3:27 What OAuth security risks should you recognize? 4:20 Outro
Affiliate notice: Some links may earn a commission. Thanks for your support.
Key Takeaways
OAuth 2.0 delegates limited access without sharing your password. The authorization server issues access tokens; the resource server validates them and enforces permissions.
Authorization is not authentication. OAuth controls what an app can access; OpenID Connect adds standardized sign-in and identity information.
Authorization code flow with PKCE protects the code exchange. After authorization, the app exchanges a temporary code plus its original PKCE verifier for an access token.
Codes and tokens have different jobs. Authorization codes obtain tokens, access tokens authorize API requests, and refresh tokens request new access tokens. Access tokens are not always JWTs.
Grant only necessary scopes. Check app identity, question excessive permissions, and remove unused connections, MFA does not prevent you from authorizing a malicious app.
Protect tokens like credentials. A stolen bearer token may enable access without your password; PKCE does not protect an already-stolen access token.
Logout may not immediately revoke API access. Follow the providerโs revocation procedures; existing access tokens may remain valid until expiration.
Use current security practices: PKCE, exact redirect URI matching, and proper token validation. OAuth security best practice advises against the implicit grant and prohibits the password grant.
๐ Turn understanding into hands-on practice with Pluralsight, an optional next step offering guided security labs, feedback, assessments, and certification practice exams.
OAuth 2.0 lets an application access protected data without requiring you to share your account password with that application. Instead, the app receives a token representing the access it has been granted.
For example, a scheduling app might need to read your calendar. OAuth lets you authorize that access without giving the scheduling app your calendar account credentials.
To understand how OAuth 2.0 works, follow three things: who requests access, which permissions are granted, and how the application uses its token.
What Is OAuth 2.0?
OAuth 2.0 is an authorization framework. It enables an application to obtain limited access to protected resources, either on a userโs behalf or on its own behalf.
Those resources might include calendar events, cloud files, email, or information exposed through an application programming interface, or . An API lets software request data or actions from another service.
Some links may earn a commission. Thanks for your support.
Watch in the video playerOpen the dedicated player for this video.
API
The central idea is delegated access:
You keep your account credentials with the account provider.
The application requests specific permissions.
The authorization service evaluates the request.
The application receives an access token if access is approved.
The API checks that token before allowing an operation.
Think of it as issuing a limited visitor badge rather than handing over a buildingโs master key. The badge grants particular access, but it still needs protection.
Without delegated authorization, a third-party application might ask for your username and password to another service. That creates several problems: the application receives reusable credentials, its access may be difficult to limit, and withdrawing access can require changing your password.
OAuth separates the applicationโs permission to access data from possession of your account password.
For example, a scheduling tool could receive permission to read calendar availability rather than broad access to your entire account. The exact permissions available depend on the provider.
OAuth does not eliminate passwords or multifactor authentication. The provider may still use them to authenticate you. The important difference is that the third-party app does not need to receive those credentials.
The Four Roles in OAuth 2.0
Imagine a fictional scheduling application called MeetingHelper requesting access to Aliceโs calendar.
OAuth role
What it does
Calendar example
Resource owner
Can authorize access to a protected resource
Alice
Client
Requests access to the resource
MeetingHelper
Authorization server
Evaluates authorization requests and issues tokens
The calendar providerโs authorization service
Resource server
Hosts protected resources and enforces access
The calendar API
In OAuth terminology, client means the application, not the person using it.
One provider can operate both the authorization server and the resource server. They remain separate logical roles: one issues tokens, while the other checks them when serving protected data.
How Does OAuth 2.0 Work? Authorization Code Flow With PKCE
A common modern approach is the authorization code flow with PKCE. PKCE stands for Proof Key for Code Exchange and is commonly pronounced โpixie.โ
This flow uses an intermediate authorization code before issuing an access token. PKCE helps ensure that someone who intercepts the code cannot simply redeem it.
1. The Application Is Registered
Before the exchange, the application is registered or otherwise configured with the authorization service.
Its configuration includes:
A client ID, which identifies the application.
A redirect URI, also called a callback address, where the provider may return the browser.
Application credentials where appropriate for a confidential server-side client.
A client ID is not a password. Also, an application distributed to users cannot reliably protect a shared secret merely by embedding it in its code.
2. The App Creates a PKCE Verifier and Challenge
For the authorization attempt, the app creates a random value called a code verifier. It then derives a code challenge from that verifier.
With the S256 method, the challenge is derived using SHA-256 and Base64url encoding.
The app keeps the verifier for the later token exchange and includes the challenge in its authorization request.
3. The Browser Goes to the Authorization Server
MeetingHelper sends Aliceโs browser to the calendar providerโs authorization endpoint.
The request includes information such as:
The appโs client ID.
The requested permissions, called scopes.
The registered redirect URI.
The PKCE code challenge.
Commonly, a state value used to correlate the response with the initiating interaction.
A scope might represent permission to read calendar information. Scope names and their meanings are defined by the provider; an example such as calendar.read is not universal.
4. The Provider Authenticates the User and Evaluates Access
The provider authenticates Alice if necessary and determines whether the requested access is allowed.
This may involve a consent screen, previously recorded consent, or organizational policy. Alice does not necessarily have to enter a password or approve a new prompt every time.
In this flow, Alice authenticates with the provider, not by giving MeetingHelper her provider password.
5. The Provider Returns an Authorization Code
If access is approved, the provider redirects Aliceโs browser to MeetingHelperโs registered callback address with a temporary authorization code.
The authorization code is not the access token. It is an intermediate credential that the app must exchange.
6. The App Exchanges the Code for Tokens
MeetingHelper sends the authorization code and its original PKCE verifier to the providerโs token endpoint over an encrypted connection.
The authorization server checks that the verifier matches the earlier challenge. A confidential client also authenticates where required.
If the exchange succeeds, the server returns an access token and may also issue a refresh token.
7. The App Uses the Access Token to Call the API
MeetingHelper presents the access token to the calendar API. A typical bearer-token request includes this HTTP header:
Authorization: Bearer <access_token>
The resource server validates the token and checks whether it permits the requested action.
A token does not grant unlimited access simply because it exists. It must be valid for the intended resource and the requested operation.
8. The App Renews Access if Permitted
If the app received a refresh token, it can later present that credential to the authorization server to request a new access token.
Renewal remains subject to provider policy. A refresh token is not a promise of permanent access.
Here is the exchange in simplified form:
App โ Authorization server: Request access with PKCE challenge
User โ Authorization server: Authenticate and authorize as needed
Authorization server โ App via browser: Authorization code
App โ Token endpoint: Code + original PKCE verifier
Token endpoint โ App: Access token; possibly refresh token
App โ Calendar API: Request + access token
Calendar API โ App: Authorized data
This describes the authorization code pattern, not every OAuth flow.
Authorization Codes, Access Tokens, and Refresh Tokens
These credentials serve different purposes and should not be treated as interchangeable.
Credential
Purpose
Where it goes
Authorization code
Temporary credential exchanged for tokens
Authorization serverโs token endpoint
Access token
Represents permission to access an API
Resource server
Refresh token
Requests new access tokens
Authorization serverโs token endpoint
ID token
Provides authentication information through OpenID Connect
Client application
An ID token belongs to OpenID Connect, not OAuth authorization by itself. It is not a substitute for an API access token.
Are OAuth Tokens Always JWTs?
No. JWT is a token format, not another name for OAuth.
An access token may be a JSON Web Token, or it may be an opaque value that does not expose an application-readable claims structure.
When an API accepts JWT access tokens, simply decoding the token is not validation. Appropriate checks include the signature, issuer, intended audience, and expiration.
What Does โBearer Tokenโ Mean?
With an ordinary bearer token, possession can be enough to use it. Someone who steals a usable bearer access token may access protected resources without knowing the userโs password.
That is why tokens must be protected from exposure in logs, URLs, storage, and other locations.
OAuth vs. Authentication vs. OpenID Connect
The most important distinction is:
Authentication: Who are you?
Authorization: What are you allowed to access or do?
OAuth 2.0 primarily addresses authorization. OpenID Connect, or OIDC, adds standardized authentication on top of OAuth 2.0.
Concept
Main purpose
OAuth 2.0
Grants applications access to protected resources
In an OIDC sign-in, the application requests the openid scope and receives an ID token. An existing identity-provider session can reduce repeated authentication prompts across applications.
Signing into an app and allowing it to read your calendar are still distinct decisions, even when they appear in one interaction.
Not every OAuth interaction involves a user approving access in a browser.
For example, a monitoring service may use client credentials to retrieve infrastructure metrics. A smart TV may display a code that the user enters on a phone to complete device authorization.
Older implementations may also expose legacy flows. Current OAuth security best practice, RFC 9700, says clients should not use the implicit grant and must not use the resource owner password credentials grant.
OAuth Security Risks and Practical Protections
OAuth reduces password sharing, but it does not make every application or permission request safe.
Consent Phishing and Excessive Permissions
In consent phishing, an attacker persuades a user to authorize a malicious application.
The user may authenticate successfully, even with MFA, and still approve dangerous access. The problem is the authorization decision, not necessarily stolen login credentials.
Before approving an app:
Check that it is the application you intended to connect.
Compare the requested permissions with its actual purpose.
Question access that seems broader than necessary.
Decline the request if you cannot justify the permissions.
Review connected applications regularly and remove access you no longer need.
A tool that only needs calendar availability should not receive unrelated access without a clear reason. Apply least privilege: grant only what is necessary.
Token Theft
Stolen access tokens can enable unauthorized API access. Stolen refresh tokens can create a continuing-access risk because they may be used to request new access tokens.
Developers need encrypted connections, protected token storage, appropriate token lifetimes, and safeguards against token leakage.
PKCE protects the authorization-code exchange; it does not make an already-stolen bearer access token unusable.
Resource servers must also validate tokens properly and enforce permissions. A token intended for one API should not automatically be accepted by another.
For developers, essential controls include:
Exact redirect URI matching.
PKCE for authorization code exchanges.
Proper token and claim validation.
Narrow permissions and audience restrictions.
Appropriate refresh-token replay defenses.
Assuming Logout Immediately Ends All Access
Logging out, removing consent, revoking a refresh token, and invalidating an existing access token are not universally identical actions.
Depending on the system, an already-issued access token may remain usable until it expires. When responding to suspicious app access, follow the providerโs revocation and incident-response procedures rather than assuming logout alone resolves it.
Building Your OAuth Understanding Into Practical Skills
For cybersecurity and CompTIA Security+ study, OAuth connects several important ideas: delegated authorization, least privilege, credential protection, social engineering, and access reviews.
The useful mental model is straightforward: the authorization server issues permission through tokens, and the resource server enforces that permission. Authentication may happen during the process, but OAuthโs main job is controlling access, not proving identity to the client application.
If you are ready to move beyond understanding the diagram, optional hands-on training can help you apply security concepts, identify knowledge gaps, and give your certification preparation more direction.
๐ Explore Pluralsight to practice in guided security labs, get feedback, and check your understanding with assessments and practice exams.
Affiliate notice: Some links may earn a commission. Thanks for your support.
What Is OpenID Connect (OIDC), and How Does It Work? (Explained Clearly)Next
FAQ
Quick answers to the questions people usually ask about this topic.
Does changing my password revoke an appโs OAuth access?
Not necessarily. OAuth tokens are separate from your password, and providers differ in how password changes affect existing tokens. If you suspect unwanted access, review your accountโs connected-app settings, revoke the appโs authorization, and follow the providerโs security procedures rather than relying on a password change alone.
Can an OAuth app access my data when Iโm not logged in?
Yes, if its authorization remains valid. An app can use an unexpired access token without an active browser session. If it also holds a valid refresh token, it may obtain new access tokens without asking you to sign in again, subject to the providerโs policies and the permissions granted.
Does revoking OAuth access delete data an app already collected?
No, not by itself. Revoking access limits future access according to the providerโs token-revocation behavior; it does not automatically erase information the app previously copied. To remove stored data, check the appโs deletion controls or contact its operator. Existing access tokens may also remain usable until they expire, depending on the system.
Does PKCE replace an OAuth client secret?
No. PKCE binds an authorization-code exchange to the app instance that created the code verifier. A client secret authenticates a confidential application to the authorization server. A server-side application may use both. Public applications, such as mobile apps, cannot reliably protect an embedded shared secret, so PKCE is particularly important, but it does not turn them into confidential clients.
Why does an OAuth API reject a request even when the app has an access token?
Possessing a token is not enough. The token may have expired, been revoked, been issued for a different API, or lack the scope required for the requested operation. The API must validate the token and enforce permissions. Developers should check the providerโs error response rather than assuming every rejection requires the user to sign in again.
Does multifactor authentication make every OAuth permission request safe?
No. MFA helps protect authentication, but it does not determine whether an application deserves the permissions it requests. In consent phishing, a user can complete MFA successfully and still authorize a malicious app. Check the appโs identity and request only the access needed for its purpose.
What is a useful next step after learning how OAuth 2.0 works?
Practice applying the underlying security concepts: least privilege, credential protection, access reviews, and incident response. If you want structured practice, explore Pluralsight as an optional next step for guided security labs, feedback, assessments, and practice exams that help you identify gaps and focus your certification preparation.
Affiliate link โ I may earn a commission at no additional cost to you.
Jay's Recommendation
Turn understanding into hands-on confidence
You've built the foundations. Pluralsight adds opportunities to practice in guided security labs, get feedback, and check your knowledge with assessments and practice exams, so your next step is more than another video.
๐ Put concepts to workBuild practical skills with guided security labs and feedback.
๐ฏFind your weak spotsUse assessments to focus on what needs more work.
๐Check your understandingUse practice exams to guide your certification preparation.
๐งญGive study sessions directionOrganize further learning with curated paths and progress tracking.