Search code examples
azure-active-directoryjwtazure-web-app-serviceopenid

Two identical Azure apps with different access_token format - one JWT, the other non-JWT


When accessing /.auth/me, one app has the access_token in the correct JWT format, but in the other app it's not in JWT format.

This is the valid JWT one: eyJ0eXAiOiJKV1QiLCJu...eyJhdWQiOiJodHRwczov...B84ciSKwF2oOre5n

This is the non-JWT one: PAQABAAAAAAD--DLA3VO7QrddgJg7WevrTLy

The configuration for both apps appear to be identical.

Any idea how to fix the second app to also show JWT access token?

enter image description here


Solution

    • Usually when the authentication flow configuration has not included resource as one of the parameter, the access token does not have form of a ( JSON Web Token)JWT token token format.
    • Please try to include resource with your application Id Uri or resource that your application requires . To find the App ID URI, in the Azure portal, click Azure Active Directory, click App registrations, click the service application, and then click Settings and Properties.
    • Also set the clientId and client secret in the request.

    In other cases just to access the app service you could use id_token or Bearer as response_type in authorization header as Authorization:Bearer "{your-id-token}".

    Reference:Oauth 2.0 grant credentials ,Access token request | Microsoft Docs

    You can make use of azure resource explorer to edit the properties of the app service auth to include the resource if not already included. See resource provider and types

    To get an access token, please try to set the resource using the Azure Resource Explorer.

    1. Navigate to the Resource Explorer from the App Service.
    2. Go to config > authsettings and click on Edit.

    Update the additionalLoginParams with ["resource=<Name/ID of the resource>"] and click on PUT.

    For example:

    “additionalLoginParams”: [
    “resource=https://graph.microsoft.com ”
    ]
    

    Then by saving changes and refreshing the App Service, try again and check that the value for the access token is in the form of a JWT token or not.

    enter image description here