An Azure service that provides hosted, universal storage for Azure app configurations.
Hi @Agrawal, Amit [JOICA], Welcome to the Microsoft Q&A Platform! Thank you for asking your question here.
It seems like you're looking to figure out the API calls needed to obtain an ID token and a refresh token. This usually involves interacting with Microsoft Entra ID (formerly known as Azure AD), and there are a few common approaches depending on your application's architecture.
Here’s a general outline of how you would go about this:
- Use the Microsoft Authentication Library (MSAL):
- The MSAL library is designed for acquiring tokens from Microsoft Entra ID easily. You'll typically want to choose an authentication flow that fits your application type (web app, mobile app, etc.).
- For example, the OAuth 2.0 authorization code flow is a common method used in web applications. It allows the application to get an access token and ID token after user authentication.
- Sample API Call Flow:
- Redirect your user to the Microsoft Entra authorization endpoint:
GET https://login.microsoftonline.com/{tenant}/oauth2/v2.0/authorize - After the user signs in, they will be redirected back to your specified redirect URI with an authorization code.
- Exchange the authorization code for tokens using the token endpoint:
POST https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token Content-Type: application/x-www-form-urlencoded grant_type=authorization_code &client_id={your-client-id} &client_secret={your-client-secret} &redirect_uri={your-redirect-uri} &code={authorization-code}
- Redirect your user to the Microsoft Entra authorization endpoint:
- Token Scope:
- Ensure you specify the appropriate scopes when doing the initial authorization request, which might include both access and ID token scopes (e.g.,
openid,profile,offline_accessfor a refresh token).
- Ensure you specify the appropriate scopes when doing the initial authorization request, which might include both access and ID token scopes (e.g.,
- Refresh Token:
- To obtain a new access token using the refresh token, make a similar POST request to the token endpoint, but specify
grant_type=refresh_tokenand include the refresh token in your request.
- To obtain a new access token using the refresh token, make a similar POST request to the token endpoint, but specify
Example of Refresh Token API Call:
POST https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token
Content-Type: application/x-www-form-urlencoded
grant_type=refresh_token
&client_id={your-client-id}
&client_secret={your-client-secret}
&refresh_token={your-refresh-token}
Important Notes:
- Always ensure that your application has appropriate permissions assigned in the Azure portal for accessing the necessary token scopes.
- The endpoints and flow may change slightly based on whether you’re using Azure AD or Azure AD B2C, so make sure to use the right documentation relevant to your implementation.
References:
Hope this helps you get started! If you have any further questions or need clarification on a specific part, feel free to ask!