How to pass KeychainGroup to a GraphClient, in C#

26 Views Asked by At

I have a .NET8 MAUI project, where I initialize a graph client like this:

    private static readonly string[] scopes = new[] { "https://graph.microsoft.com/.default" };
    private static readonly string tenantId = "tenant";
    private static readonly string clientId = "client";
    private static readonly TokenCredentialOptions options = new TokenCredentialOptions {
        AuthorityHost = AzureAuthorityHosts.AzurePublicCloud,
    };
    private static readonly UsernamePasswordCredential credential = new UsernamePasswordCredential("username", "password", tenantId, clientId, options);
    private static readonly GraphServiceClient graph = new GraphServiceClient(credential, scopes);

In the same file where I init this client, I am making a call through the client, like this:

 res = await graph.Solutions.BookingBusinesses["[email protected]"].Appointments.GetAsync();

Running this on an Android device produces the expected outcome, and 'res' is populated with data. However, on iOS, I get the following error: A screenshot of an error message, detailing the question. In my Entitlements.plist, I have added the string "XXXXX.com.microsoft.adalcache".

How do I pass WithIosKeychainSecurityGroup to the graph client?

1

There are 1 best solutions below

1
eengstroem On

I figured it out! At first, I just used $(AppIdentifierPrefix).com.microsoft.adalcache, but when I manually inserted the identifier, with the rest of the string, it worked. I didn't need to add .WithIosKeychainSecurityGroup.