Skip to content

azure.identity.InteractiveBrowserCredential: good/bad token depends on calling order #10243

@rfernand2

Description

@rfernand2

azure-identity==1.2.0
azure-keyvault-secrets==4.0.1
Windows 10
python 3.6.10

After creating a credential object from InteractiveBrowserCredential(), if I immediately call credential.get_token(), then the returned token can successfully be used with Microsoft Graph API.

However, if I first use the credential for a SecretClient get_secret() call, and then do the credential.get_token() call, the returned token cannot be used with Graph API - the following error is returned:

"{'error': {'code': 'InvalidAuthenticationToken', 'message': 'Access token validation failure. Invalid audience.', 'innerError': {'request-id': '09fc35e4-56ba-4740-a993-a0379c5ca524', 'date': '2020-03-10T21:03:23'}}}"

My Graph API call:

    endpoint =  "https://graph.microsoft.com/v1.0/me"
    headers = {'Authorization': 'Bearer ' + token}

    graph_data = requests.get(endpoint, headers=headers).json()
    upn = graph_data["userPrincipalName"]

Expected behavior
I expect the Graph API to work, independent of when I call get_token().

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Not a blocking problem, but seems related to another problem where, when using
DeviceCodeCredential(), the call to get_context() requires a 2nd authentication.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Azure.IdentityClientThis issue points to a problem in the data-plane of the library.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions