JWT Token - O Auth similar to Cognito

Kumar, Dheeraj 60 Reputation points
2026-04-23T13:09:45.9366667+00:00

Hello Team

Can anyone please help me create an app and sp with client and secret which should resolve JWT token as below

User's image

Microsoft Security | Microsoft Entra | Microsoft Entra ID

1 answer

Sort by: Oldest
  1. AI answer

    2026-04-23T13:10:13.89+00:00

    In Microsoft Entra ID, the equivalent of Cognito-style JWT issuance is to register an application, configure OAuth 2.0 / OpenID Connect, and then request tokens for that app. Custom claims like deep_product, deep_environment, application, and aws_account must be added by the token issuer (your app or an API) according to the standards.

    At a high level, the secure and supported approach is:

    1. Register an app in Microsoft Entra ID
      • Register the application so it can receive security tokens.
      • The app registration gives an Application (client) ID and allows configuration of redirect URIs and endpoints used to obtain tokens.
      • This app will be the OAuth/OIDC client that requests access tokens and ID tokens from Microsoft Entra ID.
    2. Use OAuth 2.0 / OpenID Connect flows to get tokens
      • Use a standard OAuth or OpenID Connect flow to obtain tokens; do not create tokens directly from username/password.
      • The Microsoft identity platform issues bearer tokens formatted as JWTs. These include:
        • Access tokens – used to call APIs.
        • ID tokens – used to sign in users and convey identity information.
        • Refresh tokens – used to obtain new access/ID tokens.
      • The app uses its client ID (and secret or certificate, depending on the flow) to authenticate when requesting tokens.
    3. Configure JWT bearer authentication in the API
      • For an ASP.NET Core API, configure JWT Bearer Authentication so the API can validate the tokens issued by Microsoft Entra ID.
      • The JwtBearerHandler validates the token signature and extracts claims for authentication and authorization.
      • Use the issuer’s public keys (asymmetric keys) to validate tokens; this is the recommended pattern.
    4. Add custom claims instead of hand-crafting tokens
      • Do not create production access tokens manually from a username/password request.
      • Use standards (OpenID Connect / OAuth) and asymmetric keys to issue tokens.
      • If custom claims like deep_product, deep_environment, application, and aws_account are needed, they should be added by the token-issuing component in accordance with these standards and then consumed by the API via JWT bearer authentication.
    5. Use secure storage and transport
      • For web apps, store tokens on a trusted backend and use secure HTTP-only cookies to communicate with the browser when appropriate.
      • Treat refresh tokens and access tokens as sensitive data.

    This pattern gives an OAuth/OIDC-based JWT similar to Cognito, with Microsoft Entra ID as the identity provider and ASP.NET Core (or another platform) validating the JWT via standard JWT bearer authentication.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

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