Authenticating Azure Functions with Auth0. See this blog post for more details.
const auth0 = require('azure-functions-auth0')({
clientId: '...',
clientSecret: '...',
domain: 'example.auth0.com'
});
module.exports = auth0(function(context, req) {
// YOUR USUAL CODE GOES HERE.
if (req.user)) {
context.res = {
body: req.user
};
}
else {
context.res = {
status: 400,
body: "The user seems to be missing"
};
}
context.done();
});
Now then when you make a call to the Http endpoint you'll need to add an Auth0 user token in the header. Eg:
GET https://functionsad5bb49d.azurewebsites.net/api/my-http-function?code=1pvuf...
Authorization: Bearer my-auth0-token
A boilerplate repository is also available to show how this works.