Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ansible- AWX login token API

I have installed Ansible-AWX and configured certain playbooks. I want to use the AWX API to run the ansible playbooks on a .net console application. However in order to do so I need a oauth token to login using the postman API. The problem is I am not able to generate the token. I have tried using the AWX cli and few other approaches still no positive results. Any leads would be appreciated.

like image 615
Manpreet Avatar asked Nov 01 '25 23:11

Manpreet


2 Answers

Give it a shot here:

curl -ku username:password -H "Content-Type: application/json" -X POST -d '{"description":"Tower CLI", "application":null, "scope":"write"}' http://<ip_address>/api/v2/users/1/personal_tokens/ | jq -r .token

like image 114
user2362699 Avatar answered Nov 04 '25 14:11

user2362699


https://github.com/ansible/tower-cli/issues/478#issuecomment-370528556

$ curl -ku ryan:ryan -H "Content-Type: application/json" -X POST -d '{"description":"Tower CLI", "application":null, "scope":"read"}' https://awx.example.org/api/v2/users/1/personal_tokens/ | python -m json.tool

{
    "application": null,
    "created": "2018-03-05T19:06:56.224538Z",
    "description": "Tower CLI",
    "expires": "2018-03-06T05:06:56.223889Z",
    "id": 4,
    "modified": "2018-03-05T19:06:56.234208Z",
    "refresh_token": null,
    "related": {
        "activity_stream": "/api/v2/tokens/4/activity_stream/",
        "user": "/api/v2/users/1/"
    },
    "scope": "read",
    "summary_fields": {
        "user": {
            "first_name": "",
            "id": 1,
            "last_name": "",
            "username": "ryan"
        }
    },
    "token": "ABy5N1fBiPujilEJjAUtmPlK8mTdGr",
    "type": "o_auth2_access_token",
    "url": "/api/v2/tokens/4/",
    "user": 1
}
like image 37
Daniel Andrzejewski Avatar answered Nov 04 '25 12:11

Daniel Andrzejewski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!