Skip to content

[Dev support]: 401 on send message and missing service principal #224

Closed
@Lory1990

Description

@Lory1990

Question

We are trying to integrate a A Teams Bot into our application. We are facing issues with authentication and getting errors related to the Azure AD application and service principal.

At each try

Code snippets

import { App } from '@microsoft/teams.apps';
import { DevtoolsPlugin } from '@microsoft/teams.dev';

//Guide
//https://microsoft.github.io/teams-ai/teams/m365-toolkit.html
async function start(){
  const teamsApp = new App({
  plugins: [new DevtoolsPlugin()],
  clientId: process.env.MICROSOFT_APP_ID,
  clientSecret: process.env.MICROSOFT_APP_PASSWORD,
  tenantId: process.env.MICROSOFT_APP_TENANT_ID,
});

  teamsApp.on("message", c=>{
    c.send("Hello")
  })
  await teamsApp.start(process.env.TEAMS_PORT || 3000)
}

start();

What you have tried already

Attempt 1

  1. Created an Azure Bot Service.
  2. Retrieved the App ID and App Secret from the corresponding Azure AD App Registration.
  3. Put these credentials into our application as MICROSOFT_APP_ID, MICROSOFT_APP_PASSWORD, MICROSOFT_APP_TENANT_ID
  4. Created a development tunnel using ngrok to expose the bot endpoint.
  5. Uploaded manifest + icons into teams

When testing, we received the following error on start:

AADSTS7000229: The client application xxxxx-xx-xx-xx-xxxxxxxx is missing service principal in the tenant xxxx-xx-xxx-xxx-xxxxxx.
See instructions here: https://go.microsoft.com/fwlink/?linkid=2225119 

then the app crashes

And if we create the application service principal using pwsh the message is still the same

Attempt 2

  1. Created an Azure Bot Service.
  2. Created a new App Registration under the same Azure Bot Service (with collaborator role).
  3. Put these credentials into our application as MICROSOFT_APP_ID, MICROSOFT_APP_PASSWORD, MICROSOFT_APP_TENANT_ID
  4. Created a development tunnel using ngrok to expose the bot endpoint.
  5. Uploaded manifest + icons into teams

When trying to send a message, we received a 401 Unauthorized error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions