Skip to content

Instantly share code, notes, and snippets.

@jamesmundy
Last active November 19, 2018 23:57
Show Gist options
  • Save jamesmundy/6e16b10491b6772150cf0bad747530c8 to your computer and use it in GitHub Desktop.
Save jamesmundy/6e16b10491b6772150cf0bad747530c8 to your computer and use it in GitHub Desktop.
Code showing how to set up your Azure Function to authorize bot framework requests
using (BotService.Initialize())
{
// authenticate incoming request and add activity.ServiceUrl to MicrosoftAppCredentials.TrustedHostNames
// if request is authenticated
if (!await BotService.Authenticator.TryAuthenticateAsync(req, new[]
{
activity
},CancellationToken.None))
{
return BotAuthenticator.GenerateUnauthorizedResponse(req);
}
return new HttpResponseMessage(HttpStatusCode.OK);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment