@@ -47,6 +47,8 @@ Your app would check for:
47
47
- an "error" parameter with the value "insufficient_claims"
48
48
- a "claims" parameter
49
49
50
+ # [ .NET] ( #tab/dotnet )
51
+
50
52
When these conditions are met, the app can extract and decode the claims challenge using MSAL.NET ` WwwAuthenticateParameters ` class.
51
53
52
54
``` csharp
@@ -97,7 +99,69 @@ _clientApp = PublicClientApplicationBuilder.Create(App.ClientId)
97
99
98
100
You can test your application by signing in a user to the application then using the Azure portal to Revoke the user 's sessions. The next time the app calls the CAE enabled API, the user will be asked to reauthenticate.
99
101
102
+ # [JavaScript](#tab/JavaScript)
103
+
104
+ When these conditions are met , the app can extract the claims challenge from the API response header as follows :
105
+
106
+ ```javascript
107
+ const authenticateHeader = response .headers .get ('www-authenticate' );
108
+ const claimsChallenge = authenticateHeader
109
+ .split (' ' )
110
+ .find ((entry ) => entry .includes ('claims=' ))
111
+ .split ('claims="' )[1 ]
112
+ .split ('",' )[0 ];
113
+ ```
114
+
115
+ Your app would then use the claims challenge to acquire a new access token for the resource .
116
+
117
+ ```javascript
118
+ let tokenResponse ;
119
+
120
+ try {
121
+
122
+ tokenResponse = await msalInstance .acquireTokenSilent ({
123
+ claims : window .atob (claimsChallenge ), // decode the base64 string
124
+ scopes : scopes , // e.g ['User.Read', 'Contacts.Read']
125
+ account : account , // current active account
126
+ });
127
+
128
+ } catch (error ) {
129
+
130
+ if (error instanceof InteractionRequiredAuthError ) {
131
+
132
+ tokenResponse = await msalInstance .acquireTokenPopup ({
133
+ claims : window .atob (claimsChallenge ), // decode the base64 string
134
+ scopes : scopes , // e.g ['User.Read', 'Contacts.Read']
135
+ account : account , // current active account
136
+ });
137
+ }
138
+
139
+ }
140
+ ```
141
+
142
+ Once your application is ready to handle the claim challenge returned by a CAE -enabled resource , you can tell Microsoft Identity your app is CAE -ready by adding a `clientCapabilities ` property in the MSAL configuration .
143
+
144
+ ```javascript
145
+ const msalConfig = {
146
+ auth : {
147
+ clientId : 'Enter_the_Application_Id_Here' ,
148
+ clientCapabilities : [" CP1" ]
149
+ // the remaining settings
150
+ // ...
151
+ }
152
+ }
153
+
154
+ const msalInstance = new PublicClientApplication (msalConfig );
155
+
156
+ ```
157
+
158
+ -- -
159
+
160
+ You can test your application by signing in a user and then using the Azure portal to revoke the user 's session. The next time the app calls the CAE-enabled API, the user will be asked to reauthenticate.
161
+
100
162
## Next steps
101
163
102
164
- [Continuous access evaluation ](.. / conditional - access / concept - continuous - access - evaluation .md ) conceptual overview
103
165
- [Claims challenges , claims requests , and client capabilities ](claims - challenge .md )
166
+ - [React single - page application using MSAL React to sign - in users against Azure Active Directory ](https :// github.com/Azure-Samples/ms-identity-javascript-react-tutorial/tree/main/2-Authorization-I/1-call-graph)
167
+ - [Enable your ASP .NET Core web app to sign in users and call Microsoft Graph with the Microsoft identity platform ](https :// github.com/Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2/tree/master/2-WebApp-graph-user/2-1-Call-MSGraph)
0 commit comments