简体   繁体   中英

How to get token from Tower / AWX API?

I'm trying to access AWX API from a script Python.
The documentation has the ressource /api/v1/authtoken/ for that, however when visiting the URL: https://myHost/api/v1/authtoken/ It says that it can't find the ressource.

I also tried:

response = requests.get('https://myHost/api/login/', verify=False,
    data = json.dumps({"username": "user","password": "pass"}))
results = json.loads(response.text)
token = results['token']

But I get a:

ValueError: No JSON object could be decoded

AWX version: 10.0.0

The fine manual says that:

A GET to /api/login/ displays the login page of API browser

So = requests.get( is for sure not what you want; however, even if you were to switch to requests.post the very next line says:

It should be noted that the POST body of /api/login/ is not in JSON, but in HTTP form format. Four items should be provided in the form:

so data = json.dumps({ is also for sure also not what you want

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM