1

I know there is a lot of results when searching on the internet for the error in title but the solution proposed did not work so posting a new question.

I am trying to use to retrieve a token for my application using the following code.

import requests
from msal import ConfidentialClientApplication

clientId = "{{CLIENT_ID}}"
tenantId = "{{TENANT_ID}}"
clientSecret = "{{CLIENT_SECRET}}"
endpoint = "https://sparql..profile2.sd-testlab.com"

authority = f"https://login.microsoftonline.com/%7BtenantId%7D"

app = ConfidentialClientApplication(
client_id=clientId,
client_credential=clientSecret,
authority=authority
)

s = \["https://graph.microsoft.com/.default"\]
result = app.acquire_token_for_client(scopes=s)

if "access_token" not in result:
print(result.get("error"))
print(result.get("error_description"))
print(result.get("correlation_id"))  # You may need this when reporting a bug

header = {"Authorization": "Bearer " + result\["access_token"\]}

r = requests.get(url=f'{endpoint}/databases', headers=header)
print(r)

This will return a 401, and when I look at the server log I see Failed verify the JWT: There is no issuer named https://sts.windows.net/{{TENANT_ID}} and Header token API authorization failed: Authentication failed for account 'bearer'

I configure my application as the following:

Web

Grant

After some internet search, I found many had this issue and resolved it by editing the manifest and setting "accessTokenAcceptedVersion": 2 but unfortunately, it did not resolve my issue.

accessTokenAcceptedVersion

I did see that some experience delays of a few hours, but it has been over 24 hours and I am still encountering the issue.

Any help including troubleshooting tips and resources will be very much appreciated.

0 Answers0