ADAL for iOS exceptions with a different user input

I am using the ADAL iOS library for Azure authentication. However, I had a problem if I first signed up with one account, and then log out and log in to another account. I get the following error even if I set AD_PROMPT_ALWAYS.

2015-08-31 12:50:39.939 PortalDev[908:174411] ADALiOS [2015-08-31 11:50:39 - xxx-xxx-xxx-xxx-xxx] ERROR: Error raised: 19. Additional Information: Domain: ADAuthenticationErrorDomain ProtocolCode:(null) Details:Different user was authenticated. Expected: ' aaa@xxx.com '; Actual: ' bbb@xxx.com '. Either the user entered credentials for different user, or cookie for different logged user is present. Consider calling acquireToken with AD_PROMPT_ALWAYS to ignore the cookie.. ErrorCode: 19. 2015-08-31 12:50:39.943 PortalDev[908:174411] ADAL Error: 19, Different user was authenticated. Expected: ' aaa@xxx.com '; Actual: ' bbb@xxx.com '. Either the user entered credentials for different user, or cookie for different logged user is present. Consider calling acquireToken with AD_PROMPT_ALWAYS to ignore the cookie. (status: 2) 

I cleared the cache and tried and cleared the cookies that I think are:

 if (allItems.count > 0) { [cache removeAllWithError:&error]; if (error) { CLSNSLog(@"Error clearing cache: %@", error.errorDetails); } else { CLSNSLog(@"Items removed."); } } else { CLSNSLog(@"Was no user cached."); } NSHTTPCookieStorage* cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; NSArray* cookies = cookieStorage.cookies; if (cookies.count) { for(NSHTTPCookie* cookie in cookies) { CLSNSLog(@"Deleting Auth Cookie %@.", cookie.name); [cookieStorage deleteCookie:cookie]; } CLSNSLog(@"Auth Cookies cleared."); } 

But I do not think the cookies have been cleared. The username is pre-populated when I get the login web page. I thought this worked fine a few weeks / months ago, but now there is a problem. Today I am building a library from the latest GitHub source.

Any suggestions on how I can make the username change possible?

0
source share
1 answer

The error message says:

Expected: ' aaa@xxx.com '; Actual: ' bbb@xxx.com '

This indicates that the userId parameter is being passed to receive a Token. This will populate the username field on the login page. However, the error indicates that when the user logged in, the user changed the username field to another user. Since you requested a specific user but did not receive a token for that user, acquiring Token returns an error. See this answer for more details:

ADAL iOS - The user has been authenticated differently. Expected userA@mydomain.com , actual userB@mydomain.com

0
source

All Articles