Public Keys to decode Azure AD (all microsoft accounts) Access tokens

Gautam Manoharan 11 Reputation points
2021-08-09T05:35:58.067+00:00

I am trying to decode the Access tokens and ID tokens generated by Azure Active Directory.

I have been successful with the single tenant apps, but when decoding this type of app:

Accounts in any organizational directory (Any Azure AD directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox)

I cannot find the public key corresponding to the "kid" I receive in the jwt header.

I have tried searching through the following discovery urls:

https://login.microsoftonline.com/{tenant_id}/discovery/keys
https://login.microsoftonline.com/common/discovery/keys
https://login.microsoftonline.com/{tenant_id}/discovery/keys?appid={client_id}

Please help me with the discovery url or the public key to use for these type of apps where the user can use any microsoft user account to sign in.

Microsoft Security | Microsoft Entra | Microsoft Entra ID
{count} votes

1 answer

Sort by: Most helpful
  1. Byron Lloyd - Wakeman 0 Reputation points
    2025-02-10T21:43:52.6033333+00:00

    Hi all, just been working on this problem. I'm presuming that you're using AAD B2C flows since I get the same kid. Try using this url - https://{tenant}.b2clogin.com/{tenant}.onmicrosoft.com/{policy-name} /discovery/v2.0/keys (policy name could B2C_1_SignIn for example). This should give the metadata of the user flow. Which should also include jwk_url, which should also have the correct key inside. :)

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.