I want to log in into VASK API with a python script but is does not work. This is my Code, maybe you may help me.
import requests
VAST = 'https://xx.xxx.xxx.xx/api/latest'
username = 'xxxxxx'
password = "xxxxxxxxxxx"
def login(username, password):
url = f'{VAST}'
data = {
'username': username,
'password': password
}
response = requests.post(url, data=data)
return response.json()
if __name__ == "__main__":
auth_response = login(username, password)
if auth_response and 'token' in auth_response:
print('connected')
print(f'Authentifizierungs-Token: {auth_response["token"]}')
else:
print('error')
I think that your missing part is the headers:
You can even test on your local machine:
Dummy LocalServer (run on the terminal, python local_server.py):
Your VAST Login requester (run on another terminal with and without headers):
Output (no error):