Skip to content

Latest commit

 

History

History
33 lines (26 loc) · 1.44 KB

acquiring-tokens-with-authorization-codes.md

File metadata and controls

33 lines (26 loc) · 1.44 KB
title description author manager ms.author ms.date ms.reviewer ms.service ms.subservice ms.topic
Acquire tokens with authorization codes
The Authorization Code flow is suitable when the application requires the user's interaction with the Microsoft Entra STS during authentication.
Dickson-Mwendia
CelesteDG
dmwendia
02/27/2024
dayodeji
msal
msal-java
conceptual

Acquire tokens with authorization codes

The Authorization Code flow is suitable when the application requires the user's interaction with the Microsoft Entra STS during authentication. One such case is when users login to Web applications (web sites) using OpenID Connect. The web application receives an authorization code which it can redeem to acquire a token for Web APIs.

Requests for authorization codes are delegated to the developer. To understand how to request an authorization code, see Authorization code flow. To construct the authorization code URL where the user will input their credentials, you can use the authorization code URL builder

Code snippet

PublicClientApplication pca = new PublicClientApplication.Builder(APP_ID)
        .authority(AUTHORITY)
        .build();

IAuthenticationResult result = pca.acquireToken(AuthorizationCodeParameters
        .builder(authCode, new URI(REPLY_URL))
        .scopes(scope)
        .build())
        .get();