AzureAD / azure-activedirectory-library-for-objc

The ADAL SDK for Objective C gives you the ability to add support for Work Accounts to your iOS and macOS applications with just a few lines of additional code. This SDK gives your application the full functionality of Microsoft Azure AD, including industry standard protocol support for OAuth2, Web API integration with user level consent, and two factor authentication support.
MIT License
178 stars 113 forks source link

ADTokenCache not persisted between app launches on OSX #1487

Closed aaronrogers closed 5 years ago

aaronrogers commented 5 years ago

I have a project with a iOS and OSX targets. The iOS target works great where once the user signs in they're not prompted to log in again on next app launch. However, on OSX, the user is prompted on each app launch. It appears that the ADTokenCache is empty before signing in. After signing in, there's an item in it. Restart the app, and it's gone again.

I'm calling

- (void)acquireTokenWithResource:(nonnull NSString*)resource
                        clientId:(nonnull NSString*)clientId
                     redirectUri:(nonnull NSURL*)redirectUri
                 completionBlock:(nonnull ADAuthenticationCallback)completionBlock;

What am I doing wrong?

oldalton commented 5 years ago

This is not supported by ADAL. You need to persist it yourself. Alternatively, you can use MSAL library where this is supported: https://github.com/AzureAD/microsoft-authentication-library-for-objc

aaronrogers commented 5 years ago

Sounds good. I'll check MSAL out.

Is there a reason why it works in iOS and not OSX?

oldalton commented 5 years ago

Until 10.15, macOS required different keychain implementation from iOS. ADAL never implemented it due to complexity, so we only implemented it in MSAL which is the authentication SDK going forward.

aaronrogers commented 5 years ago

Gotcha! Thanks!

oldalton commented 5 years ago

Closing the issue. Please reopen if you have additional questions. Thanks!