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

3
  • Have you seen this link: msdn.microsoft.com/en-us/library/azure/dn790557.aspx? Commented Apr 18, 2016 at 19:04
  • Basic is for username/password authentication. Try to use 'Bearer' and a base64 encoded JWT token. Commented Apr 19, 2016 at 1:13
  • Why you encode the clientid to base64, did you try use the original clientid and secretkey from app? Commented Apr 21, 2016 at 7:28

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.