Last active
April 22, 2022 11:35
-
-
Save pjirsa/4318c662adaa93541bbb767eff1dd0f5 to your computer and use it in GitHub Desktop.
Use Azure CLI to acquire access token for custom API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$appId = "04b07795-8ddb-461a-bbee-02f9e1bf7b46" #global appId for az CLI | |
$apiId = "5d6db6cd-cce5-47c4-8700-000efa22e068" #appId of your custom API | |
$requestScope = "api://localhost/5d6db6cd-cce5-47c4-8700-000efa22e068/.default" #scope exposed by your custom API app registration | |
## First time only | |
az login | |
az ad sp create --id $appId | |
az ad app permission grant --id $appId --api $apiId --scope "access_as_user" | |
## Get new token | |
az account get-access-token --scope $requestScope --query accessToken |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment