HTTPS bad request problem
Posted: Wednesday 19 September 2018 14:39
I am trying to convert a requests based HTTPS call into the python framework but struggling to get it to work. The original call is as follows:
base_url = "https://api.life360.com/v3/"
token_url = "oauth2/token.json"
The plugin call si as follows:
but results in a HTTP BAD REQUEST error (the connect itself is fine and onConnect gets called). Aything 'obvious I am missing? I never used the plugin this way so struggling to make it work
.
Thanks for the help!
H
ps: original code at https://github.com/harperreed/life360-python
base_url = "https://api.life360.com/v3/"
token_url = "oauth2/token.json"
Code: Select all
circles_url = "circles.json"
circle_url = "circles/"
authorization_token = "cFJFcXVnYWJSZXRyZTRFc3RldGhlcnVmcmVQdW1hbUV4dWNyRUh1YzptM2ZydXBSZXRSZXN3ZXJFQ2hBUHJFOTZxYWtFZHI0Vg=="
headers = {'Accept': 'application/json'}
authheader="Basic " + authorization_token
headers.update({'Authorization': authheader, 'cache-control': "no-cache",})
url = self.base_url + self.token_url
params = {
"grant_type":"password",
"username":self.username,
"password":self.password,
}
r = requests.post(url, data=params, headers=headers)
Code: Select all
self.authorization_token = "cFJFcXVnYWJSZXRyZTRFc3RldGhlcnVmcmVQdW1hbUV4dWNyRUh1YzptM2ZydXBSZXRSZXN3ZXJFQ2hBUHJFOTZxYWtFZHI0Vg=="
params = {
"grant_type": "password",
'username': self.username,
'password': self.password,
}
headers = { 'Content-Type': 'application/json; charset=utf-8', \
'Accept': 'application/json', \
'cache-control': "no-cache", \
'Authorization': "Basic " + self.authorization_token, \
'User-Agent':'Domoticz/1.0' }
Connection.Send({'Verb':'POST', 'URL':self.token_url, 'Headers': headers, 'Data': params})

Thanks for the help!
H
ps: original code at https://github.com/harperreed/life360-python