How do I authenticate with Stackato 3.x?

Posted by jamesf on 2014-05-29 09:38
OS: All / Any | Product: Stackato | tags: authentication http stackato
Question: 

I'm writing a script that interacts with Stackato. How do I get an authorization token?

Answer: 

In this example, let's assume your Stackato host is stackato.example.com and your Username/Password are JamesF/securepass

Issue an HTTP POST to the aok endpoint of your Stackato system. This will usually be similar to the api endpoint, but begin with "aok", something like "http://aok.stackato.example.com".

The POST request should contain an AUTHORIZATION header with a value of "Basic Y2Y6" and the parameters should be username, password and a parameter "grant_type" with a value of "password":

username=JamesF&password=securepass&grant_type=password

Thus, here is an example request using cURL:

$ curl -k -H 'AUTHORIZATION: Basic Y2Y6' -d "username=JamesF&password=securepass&grant_type=password"
https://aok.stackato.example.com/uaa/oauth/token

From this request you should receive an access token which can then be used in an Authorization header for future REST requests. For example, to then get Stackato usage as an admin, you might issue:

$ curl -k -H 'Authorization: bearer <access_token>' https://api.stackato.example.com/v2/usage