question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Microsoft.Identity.Client.MsalClientException: The application does not have keychain access groups enabled...failure to save to the iOS keychain.

See original GitHub issue

Which Version of MSAL are you using ? MSAL 2.5.0-Preview

Which platform has the issue? xamarin iOS

What authentication flow has the issue?

  • Desktop / Mobile
    • Interactive

Repro We currently have an interoperability issue with MSAL and Microsoft App Center. We have set up MSAL correctly with the required keychain sharing capabilities in Entitlements.plist. We build in Azure Devops using an ad-hoc provisioning profile which includes the UUIDS of all our development devices. Our builds work fine and we can successfully authenticate against our Azure B2C and access Azure resources.

Our issue manifests when we try to push the app to new iOS testers whose devices are provisioned via App Center’s automatic provisioning. When checking the output from the OSX codesign tool, we see:

In the original working build from ADO, this is the output (with our AppID redacted)

??qq1<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
       <key>get-task-allow</key>
       <false/>
       <key>application-identifier</key>
       <string>XXXXXXXXXX.XXX.XXXXXXXX.XXXXXX.app</string>
       <key>com.apple.developer.team-identifier</key>
       <string>XXXXXXXXXX</string>
       <key>keychain-access-groups</key>
       <array>
              <string>XXXXXXXXXX.com.microsoft.adalcache</string>
       </array>
       <key>com.apple.developer.healthkit</key>
       <true/>
</dict>
</plist>
 

In the newly re-signed build from App Center, this is what we see.

??qq?<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
       <key>application-identifier</key>
       <string>XXXXXXXXXX.XXX.XXXXXXXXXXX.XXXXXXX.app</string>
       <key>com.apple.developer.associated-domains</key>
       <string>*</string>
       <key>com.apple.developer.healthkit</key>
       <true/>
       <key>com.apple.developer.healthkit.access</key>
       <array>
              <string>health-records</string>
       </array>
       <key>com.apple.developer.team-identifier</key>
       <string>XXXXXXXXXX</string>
       <key>get-task-allow</key>
       <false/>
       <key>keychain-access-groups</key>
       <array>
              <string>XXXXXXXXXX.*</string>
       </array>
</dict>
</plist>

We suspect that the problem is the expansion using wildcards of the keychain access groups because if we purposely setup our entitlements.plist to contain this form, then our ADO build (which normally works) throws the same MSAL exception.

We’ve raised this with the App Center team who have been able to reproduce the same issue.

Expected behavior MSAL to save access token.

Actual behavior MSAL authenticates ok, but then throws an exception:

Microsoft.Identity.Client.MsalClientException: The application does not have keychain access groups enabled in the Entitlements.plist. As a result, there was a failure to save to the iOS keychain.

Possible Solution MSAL to save access token in local keychain if fails to write to shared keychain.

Additional context/ Logs / Screenshots https://stackoverflow.com/questions/53829119/xamarin-with-msal-cannot-save-access-token-as-keychain-access-groups-changed-dur?noredirect=1#comment94998265_53829119

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:22

github_iconTop GitHub Comments

2reactions
JohnLivermorecommented, Dec 17, 2019

@Corneliuskruger yep, that was it. I didn’t have the Entitlements for the build config used in appcenter. I fixed that and it worked.

1reaction
Corneliuskrugercommented, Dec 14, 2019

Hi @jennyf19,

Thank you so much, that was exactly it. Somehow I lost that in my Debug configuration. (all other still had it.).

@JohnLivermore, sounds like you are using a different build configuration for building in AppCenter. So maybe just double check that you have the Entitlements.plist set in that build config.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to find keychain in entitlements.plist using MSAL ...
MSAL v 4.37.0 Microsoft.Identity.Client.MsalClientException "The application does not have keychain access groups enabled in the ...
Read more >
The application has no keychain access groups enabled
Identity.Client.MsalClientException: The application does not have keychain access groups enabled in the Entitlements.plist. As a result, there ...
Read more >
Where did Keychain Access Groups entitlements go
I understand that this entitlement is now rolled into "App Groups", but I don't see my preexisting "Access Group" identifier listed on my...
Read more >
The application has no keychain access groups enabled
MsalClientException : The application does not have keychain access groups enabled in the Entitlements.plist. As a result, there was a failure to save...
Read more >
iOS: Enabling/disabling keychain access groups may not ...
If you enable keychain access groups (“Enable Keychain”) in the Entitlements.plist of a new Xamarin.iOS project, any future changes to disable them again ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found