Share via

Microsoft Graph Application AddPassword

Adrian Fiat 1 Reputation point
2022-02-03T17:57:08.8+00:00

Hello,
I am trying to automate the creation of some Applications in a B2C tenant. I am using Microsoft.Graph.Beta and Azure.Identity libraries.
First I create an automation application and using AddPassword() method, I create a new ClientSecret for that application.
After application is created i am trying to create a new GraphServiceClient using ClientSecretCredential like this:

new GraphServiceClient(
                new ClientSecretCredential(
                    tenantId,
                    automationAppId,
                    clientSecret));

When trying to use the newly created GraphServiceClient I always get this error:
MsalServiceException: A configuration issue is preventing authentication - check the error message from the server for details. You can modify the configuration in the application registration portal. See https://aka.ms/msal-net-invalid-client for details. Original exception: AADSTS7000215: Invalid client secret provided. Ensure the secret being sent in the request is the client secret value, not the client secret ID, for a secret added to app '0fa12801-f3c7-4a65-91d1-969ae65060dd'.

If I add this line of code "await System.Threading.Tasks.Task.Delay(20000)" before creating the GraphServiceClient, all is working.

Why is this happening? The client secret is correctly returned by the call.

Thank you.

Microsoft Security | Microsoft Entra | Microsoft Entra External ID

Your answer

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