MSAL iOS SDK V 1.1.19 giving "The operation couldn’t be completed. (Foundation._GenericObjCError error 0.)" issue sometimes during silent access token refresh.

Mohd Haider 6 Reputation points
2021-06-14T20:44:12.747+00:00

I am getting this error sometimes when I am trying to access the existing account from SAML iOS SDK.

Error: The operation couldn’t be completed. (Foundation._GenericObjCError error 0.)

I am not sure where I am doing wrong. I can sign in successfully and can perform silent access token refresh also but sometimes I am not getting the current sign-in account.

    let authority = try MSALAuthority(url: “authorise url”)   
    let config = MSALPublicClientApplicationConfig(clientId: “client Id”, redirectUri: nil, authority: authority)   
    self.applicationContext = try MSALPublicClientApplication(configuration: config)   

    let loggedAccount = try applicationContext.account(forIdentifier: "accountIdentifier")   

At this place, I am getting a failure sometimes.

Apart from that, I am also getting various other accounts that I have never sign in.

I am using this code:

    let allAccounts = try applicationContext.allAccounts()

This code sometimes giving me accounts that I have never sign in and it does not have my current sign-in account. That leads to silent token refresh failure.

I am using MSAL version 1.1.19 by Cocoapods now.

Microsoft Security | Microsoft Entra | Microsoft Entra ID
{count} vote

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.