Skip to content

Caching

Brandon Werner edited this page Mar 15, 2018 · 2 revisions

Caching

Caching on iOS

Keychain Setup

Click on your project in the Navigator pane in Xcode. Click on your application target and then the "Capabilities" tab. Scroll down to "Keychain Sharing" and flip the switch on. Add "com.microsoft.adalcache" to that list.

Alternatively you can disable keychain sharing by setting the keychain sharing group to nil. your application's bundle id.

    [[ADAuthenticationSettings sharedInstance] setSharedCacheKeychainGroup:nil];

Inspecting the Cache

If you need to inspect the cache in your app, you can do it through the ADKeychainTokenCache interface.

Mac OS X

Keychain Setup

Keychain is not directly supported by ADAL on Mac OS X. The default caching implementation will keep around tokens for the life time of the process, but they will not be persisted. If you wish to persist tokens you must implement the ADTokenCacheDelegate and provide it on AuthenticationContext creation

@protocol ADTokenCacheDelegate <NSObject>

- (void)willAccessCache:(nonnull ADTokenCache *)cache;
- (void)didAccessCache:(nonnull ADTokenCache *)cache;
- (void)willWriteCache:(nonnull ADTokenCache *)cache;
- (void)didWriteCache:(nonnull ADTokenCache *)cache;

@end

In this delegate you can call -serialize and -deserialize on the cache object to save or update the cache in the form of an NSData binary blob.