AzureAD / microsoft-authentication-library-for-js

Microsoft Authentication Library (MSAL) for JS
http://aka.ms/aadv2
MIT License
3.64k stars 2.65k forks source link

Cannot acquireToken() with ios webview #3328

Closed z33n00n closed 3 years ago

z33n00n commented 3 years ago

Library

Framework

Description

We are developing an Teams App and using msal-browser to authenticate our users. Everythings works fine on desktop, web and andoid, but with ios we are not able to get a token for the signed in user. SessionStorage doesn't contain any user information after signin.

Error Message

@ : Info - Emitting event: msal:ssoSilentStart
@azure/msal-browser@2.13.0 : Info - BrowserCacheManager.cleanRequestByState: Removing temporary cache items for state: eyJpZCI6IjA0Y2NkMjBjLTJlOTAtNDM5NC1iYTJjLThhYTYzMzRhZmM5MiIsIm1ldGEiOnsiaW50ZXJhY3Rpb25UeXBlIjoic2lsZW50In19
@ : Info - Emitting event: msal:ssoSilentFailure
Cannot login 'xxxx@xxxxx.onmicrosoft.com' using SSO!

{"name":"InteractionRequiredAuthError","message":"login_required: AADSTS50058: A silent sign-in request was sent but no user is signed in. The cookies used to represent the user's session were not sent in the request to Azure AD. This can happen if the user is using Internet Explorer or Edge, and the web app sending the silent sign-in request is in different IE security zone than the Azure AD endpoint (login.microsoftonline.com).\r\nTrace ID: 908ee49c-ea8a-4369-9e1b-788395205400\r\nCorrelation ID: bad0e556-7073-4112-b34f-abd11a5e5c73\r\nTimestamp: 2021-03-29 17:29:53Z","stack":"AuthError@..."}
@ : Info - Emitting event: msal:acquireTokenStart
@ : Info - Emitting event: msal:acquireTokenFromNetworkStart
@ : Info - Emitting event: msal:acquireTokenFailure
{"name":"ClientAuthError","message":"no_tokens_found: No tokens were found for the given scopes, and no authorization code was passed to acquireToken. You must retrieve an authorization code before making a call to acquireToken().","stack":"AuthError@...

sessionStorage
{"AI_sentBuffer":"[]","agentId":"8744a693-d709-40fb-85bc-f3f46e02a9d4","AI_buffer":"[]"}
localStorage
{}

MSAL Configuration

{
    auth: {
        clientId: this.clientId,
        authority: "https://login.microsoftonline.com/" + tid + "/",
        redirectUri: location.origin + "/Home/SignInEnd",
        navigateToLoginRequestUrl: false
    }, cache: {
        cacheLocation: BrowserCacheLocation.MemoryStorage,
        storeAuthStateInCookie: true
    },system: {
        loggerOptions: {
            loggerCallback: (level: LogLevel, message: string, containsPii: boolean): void => {
                if (containsPii) {
                    return;
                }
                switch (level) {
                    case LogLevel.Error:
                        console.error(message);
                        return;
                    case LogLevel.Info:
                        console.info(message);
                        return;
                    case LogLevel.Verbose:
                        console.log(message);
                        return;
                    case LogLevel.Warning:
                        console.warn(message);
                        return;
                }
            },
            piiLoggingEnabled: false
        }
    }
}

Reproduction steps

try aquireToken in a teams app with ios

Expected behavior

The same behavior like desktop, teams app or android: getting a token and store it to sessionStorage or anywhere else

Identity Provider

multitenancy

Browsers/Environment

Regression

Security

Source

github-actions[bot] commented 3 years ago

Invalid Issue Template: Please open a new issue and use one of the provided issue templates. Thanks!