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