-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Microsoft.Azure.Services.AppAuthentication.AzureServiceTokenProviderException: Exception Message: Access token could not be acquired. AADSTS7000215: Invalid client secret is provided. #11645
Comments
@stack111 @rbrundritt - Can you please have a look? |
I'll defer to stack111 as he is our Azure AD expert. |
Typically with the If you confirm with a new secret from the Azure Portal it might help narrow down the problem. There are some details regarding environment variables which could potentially be unexpected behavior with developing in IDEs. If you are developing on Windows, I would recommend adding to the system environment variables. This will persist the variable beyond application shutdown and restart. To eliminate possibility of environment variable confusion. You could also construct the object |
Thanks @stack111 . When I use the connectionString explicitly in new AzureServiceTokenProvider it works. I get my auth token. I copied the connection string out of my system environment variable called AzureServicesAuthConnectionString and pasted it directly into my code like this.
It looks like my connection string and client secret (AppKey) are correct and working. It just doesn't work if I let AzureServiceTokenProvider get it out of the environment variable like this
The error message redacts the client secret but the other fields look correct.
I am pretty sure I setup the environment variable correctly as the error message does show the expected TenantId and AppId. It looks like this: |
@jongio - the issue looks to be specific to the environment variable implementation. Can we triage the issue to a developer on the Microsoft.Azure.Services.AppAuthentication SDK? @MarneeDear - my experience when using Microsoft.Azure.Services.AppAuthentication with environment variables suggests that the application / processes might not have retrieved the variable. I would suggest closing all instances of IDEs (Visual Studio, DotNet consoles, VS Code) - The instance value of an environment variable only changes on the start of the hosting process (it is not a dynamic runtime configuration). Someone who works on the SDK would be a better help to troubleshoot why the SDK is not retrieving the value. However if you are blocked, you can use other authentication libraries to Azure AD. Any Azure AD SDK will work to call Azure Maps, each have purposes which may or may not meet your needs. Check out: |
I'll go through and update the README, but here's how I got it working with Azure.Identity You'll need the Azure CLI (https://aka.ms/azcliget) and VS Code. Clone Repo
This will get you the bits that work with Azure.Identity Service Principal
assignee is the client id from the SP you created in step 1 Set Env Vars
Set Client Id
Run it
If you get an SSL error try the HTTP instead, or run |
@MarneeDear - Did that work for you? |
Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you! |
@MarneeDear - Going to close this for now to clean up issues, but let me know if my workaround worked for you. |
Fix output-folder (Azure#11645)
Describe the bug
I get this error when I try to get an access token using AzureServiceTokenProvider.
I am using the Azure Maps AD Samples found here:
https://github.com/Azure-Samples/Azure-Maps-AzureAD-Samples/tree/master/src/ClientGrant/AzureMapsWebApiToken
I followed the directions to setup an AD App registration and give it access to the Maps. I created a client secret for this app registration and then an environment variable to store the connection string.
RunAs=App;AppId=guid;TenantId=guid;AppKey=hwblahblahfishcakes
I have verified that the AppId, TenantId, and AppKey are correct. The AppKey is the same as the Client Secret I created in the app registration.
This was working yesterday, but today I am getting an error. I haven't changed any of the code.
The code looks like this:
Expected behavior
I get an access token when calling GetAccessTokenAsync
Actual behavior (include Exception or Stack Trace)
To Reproduce
Steps to reproduce the behavior (include a code snippet, screenshot, or any additional information that might help us reproduce the issue)
Environment:
Microsoft.Azure.Services.AppAuthentication 1.4
$ dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 3.1.201
Commit: b1768b4ae7
Runtime Environment:
OS Name: Windows
OS Version: 10.0.18363
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.1.201\
The text was updated successfully, but these errors were encountered: