2

I want to use the Azure Management rest API to start and stop some Virtual Machines.

In the HTTP header I need a Authentication token as described here: Common parameters and headers.
I create a new app in the AD Section of Azure portal and added the auth token to the http header in this format:

Authorization : Basic clientID:token

where clientID:token is base64 encoded, but I am getting this error:

{"error":{"code":"AuthenticationFailedInvalidHeader","message":"Authentication failed. The 'Authorization' header is provided in an invalid format."}}

REST API - Start a virtual machine

Nk SP
  • 822
  • 4
  • 19
  • 37

1 Answers1

1

After you get the access_token, you should set HTTP Authenticate header like this:

Authorization: Bearer ACCESS_TOKEN

Basically it would look like a:

GET /subscriptions HTTP/1.1
Host: management.core.windows.net
x-ms-version: 2016-04-21
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciO.....o-ZeMSUbOlC4YEw

And you can refer to Microsoft Azure REST API + OAuth 2.0 for more help. Hope it do help.

Steven
  • 804
  • 4
  • 12