I have a python script that (successfully) returns data which includes an authorization token from BMW (that I will subsequently use to query my car's data)
I would like to convert it to vb.net so that I can write the data into Homeseer HS3. I've tried the best I can but I'm getting: (401) Unauthorized
Can anyone help me get this running?
The python (with login details removed) is:
import requests
import urllib.parse
AUTH_API = 'https://customer.bmwgroup.com/gcdm/oauth/authenticate'
class ConnectedDrive(object):
def __init__(self):
headers = {
"Content-Type" : "application/x-www-form-urlencoded"
}
values = {
'username' : 'myemailaddress',
'password' : 'mypassword',
'client_id' : 'theclientid',
'redirect_uri' : 'https://www.bmw-connecteddrive.com/app/static/external-dispatch.html',
'response_type' : 'token'
}
data = urllib.parse.urlencode(values)
r = requests.post(AUTH_API, data=data, headers=headers,allow_redirects=False)
print(r.headers['Location'])
def main():
print("Running bmw-token.py")
c = ConnectedDrive()
if __name__ == '__main__':
main()
I would like to convert it to vb.net so that I can write the data into Homeseer HS3. I've tried the best I can but I'm getting: (401) Unauthorized
Can anyone help me get this running?
The python (with login details removed) is:
import requests
import urllib.parse
AUTH_API = 'https://customer.bmwgroup.com/gcdm/oauth/authenticate'
class ConnectedDrive(object):
def __init__(self):
headers = {
"Content-Type" : "application/x-www-form-urlencoded"
}
values = {
'username' : 'myemailaddress',
'password' : 'mypassword',
'client_id' : 'theclientid',
'redirect_uri' : 'https://www.bmw-connecteddrive.com/app/static/external-dispatch.html',
'response_type' : 'token'
}
data = urllib.parse.urlencode(values)
r = requests.post(AUTH_API, data=data, headers=headers,allow_redirects=False)
print(r.headers['Location'])
def main():
print("Running bmw-token.py")
c = ConnectedDrive()
if __name__ == '__main__':
main()
Comment