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
@Supriya Saraogi To add to the below comment, Is the bot successfully registered with the bot framework where the app id and password is generated. You could try the following query using postman to check if the app id and password can be used to generate a token.
@Supriya Saraogi - Could you please confirm if your issue has resolved with above suggestion or still looking for any help?