Reputation: 3473
I am facing issue for the logout for using MSAL library.
I had used the library from : https://github.com/AzureAD/microsoft-authentication-library-for-objc
I am trying to logout and then login again with different credential but it does not work.
The function for logout is :
[self.msalClient removeUser:self.user error:&error_];
Please help
Upvotes: 1
Views: 1139
Reputation: 2446
It will store the cache for the user who logged in. So you need to remove the cache as well like this.
NSHTTPCookieStorage *cookieJar = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (NSHTTPCookie *cookie in [cookieJar cookies]) {
if ([cookie.name isEqualToString:@"MSISAuth"] ||
[cookie.name isEqualToString:@"MSISAuthenticated"] ||
[cookie.name isEqualToString:@"MSISLoopDetectionCookie"]) {
[cookieJar deleteCookie:cookie];
}
}
[self.msalClient removeUser:self.user error:&error_];
And there are some other options you can add while logging in like this
[authContext acquireTokenWithResource:resource clientId:clientId redirectUri:[NSURL URLWithString:redirectURI] promptBehavior:AD_PROMPT_ALWAYS userId:nil extraQueryParameters:nil completionBlock:^(ADAuthenticationResult *result) {
}];
Where AD_PROMPT_ALWAYS
will ask user to enter username and password every time he logged in irrespective to cache.
AD_PROMPT_REFRESH_SESSION
will open login screen but password will save. So if you touch on userId it will get required tokens.
AD_PROMPT_AUTO
based on session expire time will redirect to login
Upvotes: 2