Share via

Token request cannot be made without authorization code or refresh token when I add "teamsAppInstallation.ReadWriteSelfForChat.All" scope

Gabriel Malinosqui 0 Reputation points
2023-11-08T01:28:47.85+00:00

Hello everyone,

I'm currently facing an issue with the MSAL Node.js authentication library (msal2.js). When attempting to integrate the 'teamsAppInstallation.ReadWriteSelfForChat.All' scope into the Auth-Code flow for a Node.js application, I'm encountering the following error:

ClientAuthError: request_cannot_be_made: Token request cannot be made without authorization code or refresh token.

I'm utilizing the Authorization Code sample provided in the MSAL Node.js library, with the only modification being the addition of the aforementioned scope to my configuration. Below, I've shared the relevant segment of my customConfig.json and the primary code snippet where the error surfaces.

Custom Configuration (customConfig.json):

{
  "authOptions": {
    "clientId": "XXXXX",
    "authority": "https://login.microsoftonline.com/organizations/"
  },
  "request": {
    "authCodeUrlParameters": {
      "scopes": ["user.read", "user.read.all", "teamsAppInstallation.ReadWriteSelfForChat.All"],
      "redirectUri": "http://localhost:3000/redirect"
    },
    "tokenRequest": {
      "redirectUri": "http://localhost:3000/redirect",
      "scopes": ["user.read", "user.read.all", "teamsAppInstallation.ReadWriteSelfForChat.All"]
    }
  },
  "resourceApi": {
    "endpoint": "https://graph.microsoft.com/v1.0/me"
  }
}
// Relevant express setup and MSAL initialization code
// ...

app.get("/redirect", (req, res) => {
  const tokenRequest = {
    ...requestConfig.tokenRequest,
    code: req.query.code,
    state: req.query.state,
  };
  // Additional code for handling the token request
  // ...
});

My auth configuration on Azure Entra Admin Center:Screenshot 2023-11-07 at 22.23.03

I would greatly appreciate any insights or guidance on resolving this error. Is there an additional configuration step or permission that I'm potentially missing for this specific scope?

Thank you for your assistance!

Microsoft Security | Microsoft Entra | Microsoft Entra ID
Microsoft Security | Microsoft Graph
Microsoft Teams | Microsoft Teams for business | Other

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.