Skip to content

Commit 5311941

Browse files
committed
edits
1 parent 651555e commit 5311941

File tree

1 file changed

+16
-34
lines changed

1 file changed

+16
-34
lines changed

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

Lines changed: 16 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -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 has 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.
@@ -33,20 +33,20 @@ The following table lists possible token headers from several providers:
3333
3434
## Refresh auth tokens
3535

36-
The following information refers to refreshing provider tokens, not [session tokens](#extend-session-token-expiration-grace-period). If your provider's access token expires, you need to reauthenticate the user before you can use that token again.
36+
The following information refers to provider tokens. For session tokens, see [Extend session token expiration grace period](#extend-session-token-expiration-grace-period).
3737

38-
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 get the refreshed tokens.
38+
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-
For token refresh to work, the token store must contain [refresh tokens](/entra/identity-platform/refresh-tokens) for your provider. Each provider documents the way to get their refresh tokens. The following table provides a brief summary:
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.
4141

42-
| Provider | Refresh token |
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 |
4345
|-|-|
44-
| Microsoft | Follow the procedure in [Get Microsoft refresh tokens](#get-microsoft-refresh-tokens). |
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).|
4547
| 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/). |
4648
| 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).|
47-
| X | Access tokens don't expire. For more information, see [OAuth FAQ](https://developer.x.com/en/docs/authentication/faq)). |
48-
49-
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.
49+
| X | Access tokens don't expire. For more information, see [OAuth FAQ](https://developer.x.com/en/docs/authentication/faq). |
5050

5151
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.
5252

@@ -61,36 +61,18 @@ function refreshTokens() {
6161
}
6262
```
6363

64-
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.
65-
66-
### Get Microsoft refresh tokens
67-
68-
To get the refresh tokens, take the following steps in [Azure Resource Explorer](https://resources.azure.com).
64+
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).
6965

70-
1. At the top of the pane, select **Read/Write**.
71-
1. In the left pane, expand **subscriptions** > **\<subscription name>** > **resourceGroups** > **\<resource-group-name>** > **providers** > **Microsoft.Web** > **sites** > **\<app-name>** > **config** > **authsettingsV2**.
72-
1. Select **Edit**.
73-
1. Modify the following `loginParameters` property:
74-
75-
```json
76-
"identityProviders": {
77-
"azureActiveDirectory": {
78-
"login": {
79-
"loginParameters": ["scope=openid profile email offline_access"]
80-
}
81-
}
82-
}
83-
```
84-
85-
1. Select **Put**.
86-
87-
The scope that gives you a refresh token is [offline_access](/entra/identity-platform/scopes-oidc#the-offline_access-scope). The other scopes are already requested by App Service by default. For information on these default scopes, see [OpenID Connect Scopes](/entra/identity-platform/scopes-oidc#openid-connect-scopes).
66+
>[!NOTE]
67+
>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.
8868
8969
## Extend session token expiration grace period
9070

91-
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. 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.
71+
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.
72+
73+
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.
9274

93-
If you need a longer expiration window than 72 hours, you can extend it. 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.
75+
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.
9476

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

0 commit comments

Comments
 (0)