AzureAD / microsoft-authentication-library-for-objc

Microsoft Authentication Library (MSAL) for iOS and macOS
http://aka.ms/aadv2
MIT License
263 stars 142 forks source link

Is Async/Await support in the library? #1517

Closed idelfonsog2 closed 2 years ago

idelfonsog2 commented 2 years ago

I get the following docs

Screen Shot 2022-07-07 at 11 50 05CDT

It seems it comes from the Objective-C Interface, although other methods are not using this "magic" is it supported in all methods or not? is there a specific branch that I should use the library from? or any information related to it?

antrix1989 commented 2 years ago

Yes, the public API of the MSLA library is Objective-C based. Objective-C methods with completion blocks are automatically translated into async methods in Swift. For example:

    func abc() async throws
    {
        let a = MSALPublicClientApplication()

        let acc: MSALAccount? = nil
        let p = MSALSignoutParameters()
        try await a.signout(with: acc!, signoutParameters: p)

        let sp: MSALSilentTokenParameters? = nil
        try await a.acquireTokenSilent(with: sp!)

        let ip: MSALInteractiveTokenParameters? = nil
        try await a.acquireToken(with: ip!)
    }