Generating Cosmos DB Auth Tokens in Postman

If you read the official article that describes how access control works in Cosmos DB, you’ll see this handy Node.js function for generating authentication tokens using a master key: var crypto = require(“crypto”); function getAuthorizationTokenUsingMasterKey(verb, resourceType, resourceId, date, masterKey) { var key = new Buffer(masterKey, “base64”); var text = (verb || “”).toLowerCase() + “\n” + (resourceType… Continue reading Generating Cosmos DB Auth Tokens in Postman

Create SAS Tokens for Azure API Management with an Azure Function

Shared Access Signature (SAS) tokens are required to call Azure API Management’s original REST API. We can generate these manually on the Azure portal for testing. However, in production, if you want to invoke the APIM REST APIs programmatically, you’ll need to generate these tokens with a bit of code. There’s a snippet available in… Continue reading Create SAS Tokens for Azure API Management with an Azure Function

Extract JWT Claims in Azure API Management Policy

JSON Web Tokens (JWT) are easy to validate in Azure API Management (APIM) using policy statements. This makes integration with Azure Active Directory and other OpenID providers nearly foolproof. For example, one might add the following directive to the <inbound> policy for an API to ensure that the caller has attached a bearer token with… Continue reading Extract JWT Claims in Azure API Management Policy