Skip to content

Commit d661279

Browse files
authored
Add documentation for Azure AD v2 (#257)
1 parent f45173b commit d661279

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

docs/config-examples/azure-active-directory.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Azure Active Directory
22

3-
Azure Active Directory [does not specify a revocation endpoint](https://docs.microsoft.com/en-us/azure/active-directory/active-directory-configurable-token-lifetimes#access-tokens) because the access token are not revokable. Therefore `revoke` functionality doesn't work.
3+
Azure Active directory has two OAuth endpoints - [v1 and v2](https://docs.microsoft.com/en-us/azure/active-directory/develop/azure-ad-endpoint-comparison). Ideally, you'd want to use v2, but it has [some limitations](https://docs.microsoft.com/en-us/azure/active-directory/develop/azure-ad-endpoint-comparison#limitations), e.g. if your application relies on SAML, you'll have to use v1.
4+
5+
## V1
6+
7+
The main difference between v1 and v2 is that v2 uses _resources_ and v2 uses _scopes_ for access management.
8+
9+
V1 [does not specify a revocation endpoint](https://docs.microsoft.com/en-us/azure/active-directory/active-directory-configurable-token-lifetimes#access-tokens) because the access token are not revokable. Therefore `revoke` functionality doesn't work.
410

511
See the [Azure docs on requesting an access token](https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-protocols-oauth-code#request-an-authorization-code) for more info on additional parameters.
612

@@ -15,7 +21,6 @@ const config = {
1521
issuer: 'https://login.microsoftonline.com/your-tenant-id',
1622
clientId: 'your-client-id',
1723
redirectUrl: 'urn:ietf:wg:oauth:2.0:oob',
18-
scopes: [], // ignored by Azure AD
1924
additionalParameters: {
2025
resource: 'your-resource'
2126
}
@@ -29,3 +34,24 @@ const refreshedState = await refresh(config, {
2934
refreshToken: authState.refreshToken,
3035
});
3136
```
37+
38+
## V2
39+
40+
The V2 endpoint follows the standard OAuth protocol with scopes. Detailed documentation [here](https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-overview).
41+
42+
```js
43+
const config = {
44+
issuer: 'https://login.microsoftonline.com/your-tenant-id/v2.0',
45+
clientId: 'your-client-id',
46+
redirectUrl: 'urn:ietf:wg:oauth:2.0:oob',
47+
scopes: ['openid', 'profile', 'email', 'offline_access']
48+
};
49+
50+
// Log in to get an authentication token
51+
const authState = await authorize(config);
52+
53+
// Refresh token
54+
const refreshedState = await refresh(config, {
55+
refreshToken: authState.refreshToken,
56+
});
57+
```

0 commit comments

Comments
 (0)