how to use msal to get the access token?
Initially, I registered Microsoft Entra ID application with support account type of Single Tenant Application:
Use below modified Python Script:
from msal import ConfidentialClientApplication
CLIENT_ID = 'YOUR CLIENT ID'
CLIENT_SECRET = 'YOUR CLIENT SECRET'
TENANT_ID = 'YOUR TENANT ID'
AUTHORITY = f'https://login.microsoftonline.com/{TENANT_ID}'
SCOPE = ['https://graph.microsoft.com/.default']
REDIRECT_URI = 'http://localhost:5000/callback'
app_confidential_client = ConfidentialClientApplication(
client_id=CLIENT_ID,
client_credential=CLIENT_SECRET,
authority=AUTHORITY
)
result = app_confidential_client.acquire_token_for_client(scopes=SCOPE)
if 'access_token' in result:
print("Access Token:", result['access_token'])
else:
print("Error:", result.get("error_description", result))
Response:
If still issue persists try to register another application and try the same.
Reference: