Skip to content

Commit 05d55d0

Browse files
Merge pull request #302158 from MicrosoftDocs/main
Merged by Learn.Build PR Management system
2 parents f3d55a0 + 4ecfb3c commit 05d55d0

File tree

35 files changed

+398
-246
lines changed

35 files changed

+398
-246
lines changed

articles/api-center/includes/api-center-portal-app-registration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ If you want to create the app registration manually, follow these steps:
3535
1. Set **Name** to a meaningful name such as *api-center-portal*
3636
1. Under **Supported account types**, select **Accounts in this organizational directory (Single tenant)**.
3737
1. In **Redirect URI**, select **Single-page application (SPA)** and set the URI.
38-
Enter the URI of your API Center portal deployment, in the following form: `https://<service-name>.portal.<location>.azure-api-center.ms`. Replace `<service name>` and `<location>` with the name of your API center and the location where it's deployed, Example: `https://myapicenter.portal.eastus.azure-api-center.ms`.
38+
Enter the URI of your API Center portal deployment, in the following form: `https://<service-name>.portal.<location>.azure-apicenter.ms`. Replace `<service name>` and `<location>` with the name of your API center and the location where it's deployed, Example: `https://myapicenter.portal.eastus.azure-apicenter.ms`.
3939
1. Select **Register**.
4040

4141
#### Configure additional redirect URIs for VS Code extension
@@ -49,4 +49,4 @@ When enabling the API Center portal view in the Visual Studio Code extension for
4949
`http://localhost`<br/>
5050
`ms-appx-web://Microsoft.AAD.BrokerPlugin/<application-client-id>`<br/>
5151

52-
Replace `<application-client-id>` with the application (client) ID of this app. You can find this value on the **Overview** page of the app registration.
52+
Replace `<application-client-id>` with the application (client) ID of this app. You can find this value on the **Overview** page of the app registration.

articles/api-center/set-up-api-center-portal.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ After you create the API Center portal app registration, you need to configure a
4848
You can now access the API Center portal:
4949
* On the **Portal settings** page, select **View API Center portal** to open the portal in a new tab.
5050
* Or, enter the following URL in your browser, replacing `<service-name>` and `<location>` with the name of your API center and the location where it's deployed:<br/>
51-
`https://<service-name>.portal.<location>.azure-api-center.ms`
51+
`https://<service-name>.portal.<location>.azure-apicenter.ms`
5252

5353
### API visibility
5454

@@ -96,4 +96,4 @@ To use AI-assisted search when signed in to the API Center portal, click in the
9696

9797
## Related content
9898

99-
* [Enable and view Azure API Center portal in Visual Studio Code](enable-api-center-portal-vs-code-extension.md)
99+
* [Enable and view Azure API Center portal in Visual Studio Code](enable-api-center-portal-vs-code-extension.md)

articles/app-service/app-service-hybrid-connections.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ To install the Hybrid Connection Manager on Linux, from your terminal running as
157157
```bash
158158
sudo apt update
159159
sudo apt install tar gzip build-essential
160-
wget "https://download.microsoft.com/download/HybridConnectionManager-Linux.tar.gz"
161-
tar -xf HybridConnectionManager-Linux.tar.gz
160+
sudo wget "https://download.microsoft.com/download/HybridConnectionManager-Linux.tar.gz"
161+
sudo tar -xf HybridConnectionManager-Linux.tar.gz
162162
cd HybridConnectionManager/
163163
sudo chmod 755 setup.sh
164164
sudo ./setup.sh

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

Lines changed: 47 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,43 @@
11
---
2-
title: Work with OAuth Tokens in AuthN/AuthZ
3-
description: Learn how to retrieve tokens, refresh tokens, and extend sessions when you use the built-in authentication and authorization in Azure App Service.
2+
title: Work with OAuth Tokens in Authentication and Authorization
3+
description: Learn how to retrieve, refresh, and extend session expiration for OAuth tokens when you use Azure App Service built-in authentication and authorization.
44
ms.topic: how-to
5-
ms.date: 03/29/2021
5+
ms.date: 07/01/2025
66
ms.custom: AppServiceIdentity
77
author: cephalin
88
ms.author: cephalin
99
---
1010

11-
# Work with OAuth tokens in Azure App Service authentication
11+
# Manage OAuth tokens in Azure App Service
1212

13-
This article shows you how to work with OAuth tokens when you use the built-in [authentication and authorization in Azure App Service](overview-authentication-authorization.md).
13+
This article shows you how to manage [OAuth](https://www.microsoft.com/security/business/security-101/what-is-oauth) tokens for [built-in authentication and authorization](overview-authentication-authorization.md) in Azure App Service.
1414

1515
## Retrieve tokens in app code
1616

17-
From your server code, the provider-specific tokens are injected into the request header so that you can easily access them.
17+
Azure App Service injects your provider-specific tokens into the request header so you can easily access them. To get the provider-specific tokens, [token store](overview-authentication-authorization.md#token-store) must be enabled for the app.
1818

19-
The following table lists possible token header names:
19+
Send an HTTP `GET` request to `/.auth/me` from your client code, such as a mobile app or in-browser JavaScript. The returned JSON has the provider-specific tokens.
20+
21+
> [!NOTE]
22+
> Access tokens are for accessing provider resources, so are present only if you configure your provider with a client secret.
23+
24+
The following table lists the OAuth token header names for several App Service built-in providers:
2025

2126
| Provider | Header names |
2227
|-|-|
2328
| Microsoft Entra | `X-MS-TOKEN-AAD-ID-TOKEN` <br/> `X-MS-TOKEN-AAD-ACCESS-TOKEN` <br/> `X-MS-TOKEN-AAD-EXPIRES-ON` <br/> `X-MS-TOKEN-AAD-REFRESH-TOKEN` |
24-
| Facebook Token | `X-MS-TOKEN-FACEBOOK-ACCESS-TOKEN` <br/> `X-MS-TOKEN-FACEBOOK-EXPIRES-ON` |
29+
| Facebook | `X-MS-TOKEN-FACEBOOK-ACCESS-TOKEN` <br/> `X-MS-TOKEN-FACEBOOK-EXPIRES-ON` |
2530
| Google | `X-MS-TOKEN-GOOGLE-ID-TOKEN` <br/> `X-MS-TOKEN-GOOGLE-ACCESS-TOKEN` <br/> `X-MS-TOKEN-GOOGLE-EXPIRES-ON` <br/> `X-MS-TOKEN-GOOGLE-REFRESH-TOKEN` |
2631
| X | `X-MS-TOKEN-TWITTER-ACCESS-TOKEN` <br/> `X-MS-TOKEN-TWITTER-ACCESS-TOKEN-SECRET` |
2732

2833
> [!NOTE]
29-
> Different language frameworks might present these headers to the app code in different formats, such as in lowercase or by using title case.
30-
31-
From your client code (such as a mobile app or in-browser JavaScript), send an HTTP `GET` request to `/.auth/me` ([token store](overview-authentication-authorization.md#token-store) must be enabled). The returned JSON has the provider-specific tokens.
32-
33-
> [!NOTE]
34-
> Access tokens are for accessing provider resources, so they're present only if you configure your provider with a client secret.
34+
> Different language frameworks might present these headers to the app code in different formats, such as lowercase or title case.
3535
3636
## Refresh auth tokens
3737

38-
When your provider's access token (not the [session token](#extend-session-token-expiration-grace-period)) expires, you need to reauthenticate the user before you use that token again. You can avoid token expiration by making a `GET` call to the `/.auth/refresh` endpoint of your application. 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 by your app code get the refreshed tokens. However, for token refresh to work, the token store must contain [refresh tokens](/entra/identity-platform/refresh-tokens) for your provider. The way to get refresh tokens is documented by each provider, but the following list is a brief summary:
39-
40-
- **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).
41-
- **Facebook**: Doesn't provide refresh tokens. Long-lived tokens expire in 60 days (see [Long-Lived Access Tokens](https://developers.facebook.com/docs/facebook-login/guides/access-tokens/get-long-lived/)).
42-
- **X**: Access tokens don't expire (see [OAuth FAQ](https://developer.x.com/en/docs/authentication/faq)).
43-
- **Microsoft**: In [https://resources.azure.com](https://resources.azure.com), do the following steps:
44-
1. At the top of the pane, select **Read/Write**.
45-
1. On the explorer menu, go to **subscriptions** > *subscription name* > **resourceGroups** > *resource group name* > **providers** > **Microsoft.Web** > **sites** > *app name* > **config** > **authsettingsV2**.
46-
1. Select **Edit**.
47-
1. Modify the following property:
48-
49-
```json
50-
"identityProviders": {
51-
"azureActiveDirectory": {
52-
"login": {
53-
"loginParameters": ["scope=openid profile email offline_access"]
54-
}
55-
}
56-
}
57-
```
58-
59-
1. Select **Put**.
38+
The following information refers to provider tokens. For session tokens, see [Extend session token expiration grace period](#extend-session-token-expiration-grace-period).
6039

61-
> [!NOTE]
62-
> The scope that gives you a refresh token is [offline_access](../active-directory/develop/v2-permissions-and-consent.md#offline_access). See how it's used in [Tutorial: Authenticate and authorize users end to end in Azure App Service](tutorial-auth-aad.md). The other scopes are already requested by App Service by default. For information on these default scopes, see [OpenID Connect Scopes](../active-directory/develop/v2-permissions-and-consent.md#openid-connect-scopes).
63-
64-
After your provider is configured, you can [find the refresh token and the expiration time for the access token](#retrieve-tokens-in-app-code) in the token store.
40+
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.
6541

6642
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.
6743

@@ -76,23 +52,48 @@ function refreshTokens() {
7652
}
7753
```
7854

79-
If a user revokes the permissions 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.
55+
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).
56+
57+
>[!NOTE]
58+
>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.
59+
60+
### Configure providers to supply refresh tokens
61+
62+
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:
63+
64+
| Provider | Refresh tokens |
65+
|-|-|
66+
| Microsoft | Follow the procedure in [Configure the Microsoft Entra provider to supply refresh tokens](#configure-the-microsoft-entra-provider-to-supply-refresh-tokens). |
67+
| 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/). |
68+
| 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).|
69+
| X | Access tokens don't expire. For more information, see [OAuth FAQ](https://developer.x.com/en/docs/authentication/faq). |
70+
71+
#### Configure the Microsoft Entra provider to supply refresh tokens
72+
73+
1. In the Azure portal, go to the [API Playground (preview)](https://portal.azure.com/#view/Microsoft_Azure_Resources/ArmPlayground), and select **New request** if necessary.
74+
1. In the **Enter ARM relative path here including API version** 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`
75+
1. Select **Execute**.
76+
1. Select `PUT` at upper left, and select the **Request body** tab.
77+
1. Copy the `GET` response contents from the **Response body** field and paste them into the **Request body** tab.
78+
1. In the code, locate the `"identityProviders":` **>** `"azureActiveDirectory":` **>** `"login":` section, and add the following line:<br>`"loginParameters": ["scope=openid profile email offline_access"]`
79+
1. Select **Execute**. The **Response body** field shows your changes.
80+
81+
[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).
8082

8183
## Extend session token expiration grace period
8284

83-
The authenticated session expires after 8 hours. After an authenticated session expires, a 72-hour grace period follows by default. Within this grace period, you're allowed to refresh the session token with App Service without reauthenticating the user. You can just call `/.auth/refresh` when your session token becomes invalid, and you don't need to track token expiration yourself. When the 72-hour grace period lapses, the user must sign in again to get a valid session token.
85+
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.
8486

85-
If 72 hours isn't enough time for you, you can extend this expiration window. Extending the expiration over a long period could have significant security implications (such as when an authentication token is leaked or stolen). We recommend that you leave the setting at the default 72 hours or set the extension period to the smallest value.
87+
When the 72-hour grace period lapses, the user must sign in again to get a valid session token. If you need a longer expiration window than 72 hours, you can extend it, but extending the expiration for a long period could have significant security implications if an authentication token is leaked or stolen. It's best to leave the setting at the default 72 hours or set the extension period to the smallest possible value.
8688

87-
To extend the default expiration window, run the following command in [Azure Cloud Shell](../cloud-shell/overview.md).
89+
To extend the default expiration window, run the following Azure CLI command in [Azure Cloud Shell](../cloud-shell/overview.md):
8890

8991
```azurecli-interactive
9092
az webapp auth update --resource-group <group_name> --name <app_name> --token-refresh-extension-hours <hours>
9193
```
9294

9395
> [!NOTE]
94-
> The grace period only applies to the App Service authenticated session, not to the tokens from the identity providers. No grace period exists for expired provider tokens.
95-
>
96+
> The grace period applies only to the App Service authenticated session, not to the access tokens from the identity providers. No grace period exists for expired provider tokens.
9697
9798
## Related content
9899

0 commit comments

Comments
 (0)