Skip to content

Commit 3c9f7a6

Browse files
authored
Merge branch 'dev' into tnorling-patch-1
2 parents 366ec6a + 926f1c2 commit 3c9f7a6

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "none",
3+
"comment": "resource-and-scopes doc correction",
4+
"packageName": "@azure/msal-browser",
5+
"email": "dogan.erisen@gmail.com",
6+
"dependentChangeType": "none"
7+
}

lib/msal-browser/docs/resources-and-scopes.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
# Resources and Scopes
22

33
> :warning: Before you start here, make sure you understand how to [acquire and use an access token](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/acquire-token.md).
4+
45
Azure Active Directory v2.0 & Microsoft Identity Platform employs a *scope-centric* model to access resources. Here, a *resource* refers to any application that can be of recipient of an **Access Token** (such as [MS Graph API](https://docs.microsoft.com/graph/overview) or your own web API), and a *scope* (*aka* "permission") refers to any aspect of a resource that an **Access Token** grants rights.
56

67
**Access Token** requests in **MSAL.js** are meant to be *per-resource-per-scope(s)*. This means that an **Access Token** requested for resource **A** with scope `scp1`:
78

89
- cannot be used for accessing resource **A** with scope `scp2`, and,
910
- cannot be used for accessing resource **B** of any scope.
1011

11-
The intended recipient of an **Access Token** is represented by the `aud` claim; in case the value for the `aud` claim does not match the resource [APP ID URI](https://docs.microsoft.com/azure/active-directory/develop/scenario-protected-web-api-app-registration), the token should be considered invalid. Likewise, the permissions that an **Access Token** grants is represented by the `scp` claim. See [ Access Token claims](https://docs.microsoft.com/azure/active-directory/develop/access-tokens#payload-claims) for more information.
12+
The intended recipient of an **Access Token** is represented by the `aud` claim; in case the value for the `aud` claim does not match the resource [APP ID URI](https://docs.microsoft.com/azure/active-directory/develop/scenario-protected-web-api-app-registration), the token should be considered invalid. Likewise, the permissions that an **Access Token** grants is represented by the `scp` claim. See [Access Token claims](https://docs.microsoft.com/azure/active-directory/develop/access-tokens#payload-claims) for more information.
1213

1314
## Working with Multiple Resources
1415

@@ -28,7 +29,7 @@ Bear in mind that you *can* request multiple scopes for the same resource (e.g.
2829

2930
```javascript
3031
const graphToken = await msalInstance.acquireTokenSilent({
31-
scopes: [ "User.Read", "User.Write", "Calendar.Read"] // all MS Graph API scopes
32+
scopes: [ "User.Read", "User.Write", "Calendar.Read" ] // all MS Graph API scopes
3233
});
3334
```
3435

@@ -59,13 +60,16 @@ In **Azure AD**, the scopes (*permissions*) set directly on the application regi
5960
msalInstance.acquireTokenSilent(tokenRequest);
6061
```
6162

62-
In the code snippet above, the user will be prompted for consent once they authenticate and receive an **ID Token** and an **Access Token** with scope `User.Read`. Later, if they request an **Access Token** for `User.Read`, they will not be asked for consent again (in other words, they can acquire a token *silently*). On the other hand, the user did not consented to `Mail.Read` at the authentication stage. As such, they will be asked for consent when requesting an **Access Token** for that scope. The token received will contain all the previously consented scopes, hence the term *incremental consent*.
63+
In the code snippet above, the user will be prompted for consent once they authenticate and receive an **ID Token** and an **Access Token** with the scope `User.Read`. Later, if they request an **Access Token** for `User.Read`, they will not be asked for consent again (in other words, they can acquire a token *silently*).
64+
65+
On the other hand, the user did not consent to `Mail.Read` at the authentication stage, therefore, will be asked for consent when requesting an **Access Token** for `Mail.Read` scope. The token received will contain all the previously consented scopes (for that specific resource), hence the term *incremental consent*.
6366

6467
Consider a slightly different case:
6568

6669
```javascript
6770
const loginRequest = {
68-
scopes: [ "openid", "profile", "User.Read", "api://<myCustomApiClientId>/My.Scope" ]
71+
scopes: [ "openid", "profile", "User.Read" ],
72+
extraScopesToConsent: [ "api://<myCustomApiClientId>/My.Scope"]
6973
};
7074
const tokenRequest = {
7175
scopes: [ "Mail.Read" ]
@@ -75,9 +79,9 @@ Consider a slightly different case:
7579
}
7680
// will return an ID Token and an Access Token with scopes: "openid", "profile" and "User.Read"
7781
msalInstance.loginPopup(loginRequest);
78-
// will fail and fallback to an interactive method prompting a consent screen
82+
// will fail with InteractionRequiredError due to lack of consent for "Mail.Read" scope. You should fallback to an interactive method in this case.
7983
msalInstance.acquireTokenSilent(tokenRequest);
80-
// will succeed and return an Access Token with scopes "openid", "profile", "User.Read" and "api://<myCustomApiClientId>/My.Scope"
84+
// will succeed and return an Access Token with scope "api://<myCustomApiClientId>/My.Scope"
8185
msalInstance.acquireTokenSilent(anotherTokenRequest);
8286
```
8387

lib/msal-react/docs/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ A hook that returns the `PublicClientApplication` instance, an array of all acco
174174
You can read more about this hook in the [hooks doc](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-react/docs/hooks.md#usemsal-hook).
175175

176176
```javascript
177-
import React from 'react'l
177+
import React from 'react';
178178
import { useMsal } from "@azure/msal-react";
179179

180180
export function App() {

0 commit comments

Comments
 (0)