AspNetCoreMicrosoftGraph
AspNetCoreMicrosoftGraph copied to clipboard
Error on missing client secret / certificate
MsalClientException: IDW10104: Both client secret and client certificate cannot be null or whitespace, and only ONE must be included in the configuration of the web app when calling a web API. For instance, in the appsettings.json file.
Microsoft.Identity.Web.MicrosoftIdentityOptionsValidation.ValidateEitherClientCertificateOrClientSecret(string clientSecret, IEnumerable<CertificateDescription> cert)
Microsoft.Identity.Web.TokenAcquisition.BuildConfidentialClientApplicationAsync()
Microsoft.Identity.Web.TokenAcquisition.GetOrBuildConfidentialClientApplicationAsync()
Microsoft.Identity.Web.TokenAcquisition.AddAccountToCacheFromAuthorizationCodeAsync(AuthorizationCodeReceivedContext context, IEnumerable
Any idea what this could be ? I have passed in the client secret.
Hi @bbqchickenrobot
You need to create a secret (or certificate) in the Azure App registration and add this to your user secrets
Greetings Damien
Awesome @damienbod - that worked! Thanks for the tip and the tutorial!
Awesome @damienbod - that worked! Thanks for the tip and the tutorial!
I understand the registration of a secret part. But where did you apply the secret?
In the code in the Starupt.cs and the appsettings.json. Add an "azuread_secret": "my secret". to appsettings and load it during startup
Thanks, yes i got it now. If anyone else have the same problem as me:
dont forget to add your secrets with colon like
dotnet user-secrets set "AzureAd:ClientSecret" "secretGoesHere*********************"
When using a depth in the appsettings.json
Good to know, I was hoping I could avoid using a secret entirely and use the token for the user, but it would seem it doesn't work this way.