Azure Active Directory Authentication Samples - Huachao/vscode-restclient GitHub Wiki
Pick a directory from a list or use the default directory for the account:
GET https://management.azure.com/subscriptions
?api-version=2017-08-01
Authorization: {{$aadToken}}
Explicit directory using tenant ID:
GET https://management.azure.com/subscriptions
?api-version=2017-08-01
Authorization: {{$aadToken 00000000-0000-0000-0000-000000000000}}
Explicit directory using domain name:
GET https://management.azure.com/subscriptions
?api-version=2017-08-01
Authorization: {{$aadToken contoso.com}}
Do not reuse older token -- force re-authentication for current directory (e.g. switch account):
GET https://management.azure.com/subscriptions
?api-version=2017-08-01
Authorization: {{$aadToken new contoso.com}}
REST Client uses an in-memory token cache that clears when Visual Studio Code is restarted. You can clear the token cache manually by using
F1 > Rest Client: Clear Azure AD Token Cache
._
new
can be used with any other options, as long as it's specified first. Order is important for all options._
Specify an explicit Azure AD app (aka audience or resource):
GET https://fabrikam.com/api/foo
Authorization: {{$aadToken aud:000000000000-0000-0000-0000-00000000}}
Audience (
aud
) must be an allowed value by the target API you are calling. Usually, this is a URL ending in a slash (/), but may also be an app/client id or other value. Contact the app owner to determine valid options._
Audience (
aud
) can be used with any other options, as long as it's specified last. Order is important for all options._
Implicit cloud selection (via REST endpoint TLD):
GET https://management.microsoftazure.de/subscriptions
?api-version=2017-08-01
Authorization: {{$aadToken}}
Explicit cloud selection:
GET https://management.usgovcloudapi.net/subscriptions
?api-version=2017-08-01
Authorization: {{$aadToken us}}
Azure China does not work like the other clouds. Use of Azure China is allowed, but may fail._
Use of Azure AD is not limited to Azure APIs. Inclusion here is for demonstration purposes only._
Thanks @flanakin for implementing this feature and providing following samples.