Invalid AppId passed on token: <app_ID>

Supriya Saraogi 1 Reputation point
2022-02-15T02:15:35.697+00:00

Hi Team, I'm trying to authenticate incoming request from bot connector service to bot.
I have implemented the following code to validate the request but I'm getting error:

public boolean validateRequest(String headerAuthenticationValue, String request) throws ExecutionException, InterruptedException {
Activity botPayload = gson.fromJson(request, Activity.class);
boolean isValid = validateAuthToken(headerAuthenticationValue, botPayload);
return isValid;
}

private static boolean validateAuthToken(String headerAuthenticationValue, Activity botPayload) throws ExecutionException, InterruptedException {
CredentialProvider credentialProvider = new SimpleCredentialProvider();
CompletableFuture<ClaimsIdentity> claimsIdentity = authenticateToken(headerAuthenticationValue,
credentialProvider,
botPayload.getChannelId(),
botPayload.getServiceUrl());
if(claimsIdentity.get().isAuthenticated()){
return true;
}
return false;
}

   com.microsoft.bot.connector.authentication.AuthenticationException:Invalid AppId passed on token: <app_ID> (App id received in header)  

P.S I have not published my bot yet. I create the bot through app studio.
Documents referred - https://learn.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-connector-authentication?view=azure-bot-service-4.0#connector-to-bot

Azure AI Bot Service
Azure AI Bot Service
An Azure service that provides an integrated environment for bot development.
865 questions
Microsoft Teams
Microsoft Teams
A Microsoft customizable chat-based workspace.
10,470 questions
Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
3,408 questions
{count} votes

2 answers

Sort by: Most helpful
  1. YutongTie-MSFT 53,331 Reputation points
    2022-03-05T10:33:15.047+00:00

    Hello @Supriya Saraogi

    I hope you have solved your issue and I just want to double click on this issue to see if you need further help. I think Rohit and Chetan both pointed out "App_Id" may be the root cause, I hope you have chance to check on above workarounds.

    Please let us know if you need deeper help. Thanks.

    Regards,
    Yutong

    0 comments No comments

  2. Daniel Levy 1 Reputation point
    2022-12-12T15:10:21.187+00:00

    @romungi-MSFT , @YutongTie-MSFT
    Hi, I'm getting the same error, and I've tried using the API as you suggested from postman and got the expected result (status code 200 and a token)
    I've opened a github issue: https://github.com/microsoft/botbuilder-python/issues/1983

    please help with this since ms-teams and developer portal had and still have some other bugs that made us issues during some POC's and we would like to fix this ASAP.

    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.