You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/active-directory/develop/msal-error-handling-js.md
+64-10Lines changed: 64 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,17 +54,19 @@ The following error types are available:
54
54
55
55
-`InteractionRequiredAuthError`: Error class, extends `ServerError` to represent server errors, which require an interactive call. This error is thrown by `acquireTokenSilent` if the user is required to interact with the server to provide credentials or consent for authentication/authorization. Error codes include `"interaction_required"`, `"login_required"`, and `"consent_required"`.
56
56
57
-
For error handling in authentication flows with redirect methods (`loginRedirect`, `acquireTokenRedirect`), you'll need to register the callback, which is called with success or failure after the redirect using `handleRedirectCallback()` method as follows:
57
+
For error handling in authentication flows with redirect methods (`loginRedirect`, `acquireTokenRedirect`), you'll need to handle the promise, which is called with success or failure after the redirect using `handleRedirectPromise()` method as follows:
58
58
59
59
```javascript
60
-
functionauthCallback(error, response) {
61
-
//handle redirect response
62
-
}
63
-
64
-
var myMSALObj =newMsal.UserAgentApplication(msalConfig);
60
+
var myMSALObj =newMsal.PublicClientApplication(msalConfig);
Interactively acquiring the token prompts the user and gives them the opportunity to satisfy the required Conditional Access policy.
142
144
143
-
When calling an API requiring Conditional Access, you can receive a claims challenge in the error from the API. In this case, you can pass the claims returned in the error to the `claimsRequest` field of the `AuthenticationParameters.ts` class to satisfy the appropriate policy.
145
+
When calling an API requiring Conditional Access, you can receive a claims challenge in error from the API. In this case, you can extract the claims challenge from the `WWW-Authenticate` header from the API error response object as shown in the `handleClaimsChallenge` method.
146
+
147
+
```javascript
148
+
fetch(apiEndpoint, options)
149
+
.catch((response) => {
150
+
if (response.status===401&&response.headers.get('www-authenticate')) {
See [Requesting Additional Claims](active-directory-optional-claims.md) for more detail.
199
+
See [Requesting Additional Claims](active-directory-optional-claims.md)and [How to use Continuous Access Evaluation enabled APIs in your applications](./app-resilience-continuous-access-evaluation.md)for more detail.
0 commit comments