Skip to content

Commit 88e351a

Browse files
committed
api playground
1 parent 6f723d9 commit 88e351a

File tree

1 file changed

+30
-15
lines changed

1 file changed

+30
-15
lines changed

articles/app-service/configure-authentication-oauth-tokens.md

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Work with OAuth Tokens in Authentication and Authorization
33
description: Learn how to retrieve tokens, refresh tokens, and extend session token expiration when you use the built-in authentication and authorization in Azure App Service.
44
ms.topic: how-to
5-
ms.date: 06/26/2025
5+
ms.date: 06/30/2025
66
ms.custom: AppServiceIdentity
77
author: cephalin
88
ms.author: cephalin
@@ -14,7 +14,7 @@ This article shows you how to manage OAuth tokens when you use [built-in authent
1414

1515
## Retrieve tokens in app code
1616

17-
Provider-specific tokens are injected into the request header from your server code so you can easily access them. To get the provider-specific tokens, send an HTTP `GET` request to `/.auth/me`from your client code, such as a mobile app or in-browser JavaScript. [Token store](overview-authentication-authorization.md#token-store) must be enabled for the app. The returned JSON contains the provider-specific tokens.
17+
Provider-specific tokens are injected into the request header from your server code so you can easily access them. To get the provider-specific tokens, send an HTTP `GET` request to `/.auth/me` from your client code, such as a mobile app or in-browser JavaScript. [Token store](overview-authentication-authorization.md#token-store) must be enabled for the app. The returned JSON contains the provider-specific tokens.
1818

1919
> [!NOTE]
2020
> Access tokens are for accessing provider resources, so are present only if you configure your provider with a client secret.
@@ -37,19 +37,6 @@ The following information refers to provider tokens. For session tokens, see [Ex
3737

3838
If your provider's access token expires, you must reauthenticate the user before you can use that token again. You can avoid token expiration by making a `GET` call to the `/.auth/refresh` endpoint of your application.
3939

40-
When called, App Service automatically refreshes the access tokens in the [token store](overview-authentication-authorization.md#token-store) for the authenticated user. Subsequent requests for tokens get the refreshed tokens.
41-
42-
For token refresh to work, the token store must contain [refresh tokens](/entra/identity-platform/refresh-tokens) from your provider. Each provider documents how to get their refresh tokens. The following table provides a brief summary:
43-
44-
| Provider | Get refresh token |
45-
|-|-|
46-
| Microsoft | Follow the procedure in [Configure App Service to return a usable access token](scenario-secure-app-access-microsoft-graph-as-user.md#configure-app-service-to-return-a-usable-access-token). The scope that gives you a refresh token is [offline_access](/entra/identity-platform/scopes-oidc#the-offline_access-scope). App Service already requests other scopes by default. For more information, see [OpenID Connect Scopes](/entra/identity-platform/scopes-oidc#openid-connect-scopes).|
47-
| Facebook | Doesn't provide refresh tokens. Long-lived tokens expire in 60 days. For more information, see [Long-Lived Access Tokens](https://developers.facebook.com/docs/facebook-login/guides/access-tokens/get-long-lived/). |
48-
| Google | Append an `access_type=offline` query string parameter to your `/.auth/login/google` API call. For more information, see [Google Refresh Tokens](https://developers.google.com/identity/protocols/OpenIDConnect#refresh-tokens).|
49-
| X | Access tokens don't expire. For more information, see [OAuth FAQ](https://developer.x.com/en/docs/authentication/faq). |
50-
51-
Once you configure your provider, you can find the refresh token and the expiration time for the access token by using the headers listed in [Retrieve tokens in app code](#retrieve-tokens-in-app-code).
52-
5340
To refresh your access token at any time, call `/.auth/refresh` in any language. The following snippet uses jQuery to refresh your access tokens from a JavaScript client.
5441

5542
```javascript
@@ -63,9 +50,37 @@ function refreshTokens() {
6350
}
6451
```
6552

53+
When called, App Service automatically refreshes the access tokens in the [token store](overview-authentication-authorization.md#token-store) for the authenticated user. Subsequent requests for tokens get the refreshed tokens. You can see the refresh tokens and the expiration time for the tokens by using the headers listed in [Retrieve tokens in app code](#retrieve-tokens-in-app-code).
54+
6655
>[!NOTE]
6756
>If a user revokes the permissions they granted to your app, your call to `/.auth/me` might fail with a `403 Forbidden` response. To diagnose errors, check your application logs for details.
6857
58+
### Configure providers to supply refresh tokens
59+
60+
For token refresh to work, the token store must contain [refresh tokens](/entra/identity-platform/refresh-tokens) from your provider. Each provider documents how to get their refresh tokens. The following table provides a brief summary:
61+
62+
| Provider | Refresh tokens |
63+
|-|-|
64+
| Microsoft | Follow the procedure in [Configure App Service to return a usable access token](scenario-secure-app-access-microsoft-graph-as-user.md#configure-app-service-to-return-a-usable-access-token). |
65+
| Facebook | Doesn't provide refresh tokens. Long-lived tokens expire in 60 days. For more information, see [Long-Lived Access Tokens](https://developers.facebook.com/docs/facebook-login/guides/access-tokens/get-long-lived/). |
66+
| Google | Append an `access_type=offline` query string parameter to your `/.auth/login/google` API call. For more information, see [Google Refresh Tokens](https://developers.google.com/identity/protocols/OpenIDConnect#refresh-tokens).|
67+
| X | Access tokens don't expire. For more information, see [OAuth FAQ](https://developer.x.com/en/docs/authentication/faq). |
68+
69+
### Configure the Microsoft Entra provider to supply refresh tokens
70+
71+
1. In the Azure portal, go to the [API Playground (preview)](https://portal.azure.com/#view/Microsoft_Azure_Resources/ArmPlayground).
72+
1. In the **Enter ARM relative path here** field, enter the following string, replacing the placeholders with your subscription ID, resource group name, and app name:<br>`subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.Web/sites/<app-name>/config/authsettingsV2?api-version=2024-11-01`
73+
1. Select **Execute**.
74+
1. Copy the contents of the **Request body** field and paste them into an editor.
75+
1. In the code, add the following line to the `"identityProviders":` **>** `"azureActiveDirectory":` **>** `"login":` section:<br>`"loginParameters": ["scope=openid profile email offline_access"]`.
76+
1. In the API Playground, select **New request**.
77+
1. Select `PUT` from the command dropdown list.
78+
1. Enter the same ARM relative path and API version as for the `GET` command.
79+
1. Select the **Request body** field, and paste in your edited code.
80+
1. Select **Execute**. The **Response body** field shows your changes.
81+
82+
[Offline_access](/entra/identity-platform/scopes-oidc#the-offline_access-scope) is the scope that provides refresh tokens. App Service already requests the other scopes by default. For more information, see [OpenID Connect Scopes](/entra/identity-platform/scopes-oidc#openid-connect-scopes) and [Web Apps - Update Auth Settings V2](/rest/api/appservice/web-apps/update-auth-settings-v-2).
83+
6984
## Extend session token expiration grace period
7085

7186
The authenticated session expires after 8 hours, and a 72-hour default grace period follows. Within this grace period, you can refresh the session token with App Service without reauthenticating the user. You can simply call `/.auth/refresh` when your session token becomes invalid, and you don't need to track token expiration yourself.

0 commit comments

Comments
 (0)