Search code examples
swiftazure-ad-msal

How to get refreshToken in MSAL login for IOS


I am struggling to integrate AD login in my application. its succeeding and returning the response to the app. but now i need refreshToken as well with authToken but till now i didNot succeed to get value of refreshToken,

methods i tried:

  • acquireTokenSilently
  • acquireToken

Solution

  • MSAL obtains refresh tokens together with access tokens and caches them to later retrieve new access tokens during acquireTokenSilent. If MSALError.interactionRequired is thrown during the former then you should call acquireTokenInteractively in order to obtain new tokens.

    Take a look to the following sample: https://github.com/Azure-Samples/ms-identity-mobile-apple-swift-objc/blob/7bd269510b8d07f59a10363b326962898c4fc106/MSALiOS/ViewController.swift#L188