How to create an REST token from the command line

I am creating an unattended setup for HUB and other Jetbrains products. Right now I am blocked while I am trying to automate the creation of a token for the REST calls we use to configure the service. 

While I am actually using Ansible, it would be of great help if you could provide examples of how to get a bearer token, given user and pass, using curl. The Hub service ID is 0-0-0-0-0 and I need to manage only Hub (i.e. no other scopes are involved)

I have the admin account and password, but try as I might, I can not get a bearer token. The closest I got was if I use the service secret of the Hub service, but then how do I get the secret?...

curl -X POST -d "client_id=0-0-0-0-0&client_secret=foobar&grant_type=password&username=admin&password=secret&scope=0-0-0-0-0" http://localhost:8082/hub/api/rest/oauth2/token


I also noticed the awcToken.properties file, but I am not sure where can I use this token and what can I do with it.

2 comments
Comment actions Permalink

Hi Dimitar,

you can use basic authorization. You need to create a token like this:

token = base64(login: password)

and the request would be:

curl  -H “Authorization: Basic <token>” …….

For example: 

token = base64(admin:admin) = YWRtaW46YWRtaW4=

Please let us know if you have any further questions. Thanks!

0
Comment actions Permalink

Thank you! You may want to add this tip (that basic auth works) to the REST API help page.

0

Please sign in to leave a comment.