Managing external identities to enable secure access for partners, customers, and other non-employees
Microsoft Graph Application AddPassword
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.