Invalid JWT token. Unsupported key for the signing algorithm

IPESOFT 0 Reputation points
2025-06-16T08:51:36.9533333+00:00

Hello,

We have deployed a custom Teams Tab application. There is a manifest.json and respective AppRegistration. No error messages are displayed when user opens the application. The app itself is displayed in the Teams Store.

The problem arises when the frontend (right before accessing a screen with form) attempts to obtain a token using Microsoft @microsoft/teams-js library, method getAuthToken(). This token is not used to call Graph/Sharepoint APIs directly, but rather the application exchanges it for a Graph and/or SharePoint token to execute respective calls via backend. Upon attempting to exchange this token for a GraphAPI token using MSAL backend application, an error message is returned: "AADSTS5002730: Invalid JWT token. Unsupported key for the signing algorithm. Trace ID: 677b0e66-6284-4b6c-999f-9c8ffeffa800 Correlation ID: fe697968-cc06-48f2-9d52-25d25c49a753".

The issue seems to be the fact the original token (the one obtained by getAuthToken() method), it's signed using HS256.

Community Center | Not monitored
{count} votes

2 answers

Sort by: Most helpful
  1. Deepanshu katara 16,720 Reputation points MVP Moderator
    2025-06-16T10:08:55.0066667+00:00

    Hello , Welcome to MS Q&A

    I think you cannot exchange the HS256-signed Teams token for a Graph/SharePoint token in Azure AD. You must use the Teams SSO flow or MSAL to get a real Azure AD access token for Graph/SharePoint.

    References

    Pls check and let us know if any further ques

    Kindly accept answer if it helps

    Thanks

    Deepanshu

    0 comments No comments

  2. IPESOFT 0 Reputation points
    2025-06-17T05:57:56.86+00:00

    Hello,

    Thank you for reply. I will make little update on this.

    First, we obtain Microsoft Entra token.

    Then we try to exchange this token in OBO flow.

    In one tenant, we obtain HS256 token (as authToken), in other tenant, the very same line of code returns RS256 token. That is the issue we need to solve.

    Just to show which libs we use:

    b877179

    More of the same method:

    b470795

    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.