Samantha
Samantha

Reputation: 75

AADSTS700016: Failed to obtain access token when authenticating to Azure with MSAL

I would like to authenticate to Azure using MSAL, which I specified as follows:

 app = msal.ConfidentialClientApplication(
        client_id=client_id,
        client_credential=client_secret,
        authority='https://login.microsoftonline.com/' + tenantname
    )
    result = app.acquire_token_for_client(scopes=scopes)

It fails because it cannot find the company's tenantname I have access to even though it's correctly specified.

Error description was: AADSTS700016: Application with identifier '12341234123somethingtest-fje2434823412341234123somethingtest-4322134-213413212341234123somethingtest' was not found in the directory '213412312341234123somethingtest-1234-3241'. This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. You may have sent your authentication request to the wrong tenant. Exception: Failed to obtain access token

I've tried tenantname and tenant ID from the AAD as well and always got the same error. Is there any way to resolve this issue? (The code worked perfectly when I used it on my own Azure.)

Upvotes: 2

Views: 4814

Answers (1)

Carl Zhao
Carl Zhao

Reputation: 9519

Your error has been resolved. It is caused by lack of characters in your client_id. You only need to enter the correct client_id.

Encountered similar problems, can run admin consent url debugging in the browser:

https://login.microsoftonline.com/{tenant-id}/adminconsent?client_id={client-id}.

Upvotes: 1

Related Questions