Skip to content
This repository has been archived by the owner on Nov 11, 2022. It is now read-only.

API Server authentication issues #52

Open
rs38 opened this issue Feb 16, 2020 · 5 comments
Open

API Server authentication issues #52

rs38 opened this issue Feb 16, 2020 · 5 comments

Comments

@rs38
Copy link
Contributor

rs38 commented Feb 16, 2020

needs to be done via
https://customer.bmwgroup.com/gcdm/oauth/authenticate

please see
#23

@rs38
Copy link
Contributor Author

rs38 commented Feb 16, 2020

@havrla
Copy link

havrla commented Feb 21, 2020

resolv:
auth.txt

@havrla
Copy link

havrla commented Nov 22, 2020

BASE_URL = 'customer.bmwgroup.com'
#BASE_URL = 'b2vapi.bmwgroup.com'

def getToken(BASE_URL, username, password, timeout=(20, 20)):
    try:
        headers = {
                "Content-Type": "application/x-www-form-urlencoded",
                "Content-Length": "124",
                "Connection": "Keep-Alive",
                "Host": BASE_URL,
                "Accept-Encoding": "gzip",
                "Authorization": "Basic blF2NkNxdHhKdVhXUDc0eGYzQ0p3VUVQOjF6REh4NnVuNGNEanli"
                                 "TEVOTjNreWZ1bVgya0VZaWdXUGNRcGR2RFJwSUJrN3JPSg==",
                "Credentials": "nQv6CqtxJuXWP74xf3CJwUEP:1zDHx6un4cDjybLENN3kyfumX2kEYigWPcQpdvDRpIBk7rOJ",
                "User-Agent": "okhttp/2.60"}

        data = {
            'client_id': 'dbf0a542-ebd1-4ff0-a9a7-55172fbfce35',
            'response_type': 'token',
            'redirect_uri': 'https://www.bmw-connecteddrive.com/app/static/external-dispatch.html',
            'scope': 'authenticate_user vehicle_data remote_services',
            'username': username,
            'password': password}

        data = urllib.parse.urlencode(data)#       url = 'https://' + BASE_URL + '/webapi/oauth/token'
#        url = 'https://' + BASE_URL + '/webapi/oauth/token'
        url = 'https://' + BASE_URL + '/gcdm/oauth/authenticate'
        #print (url)
        r = requests.post(url, data=data, headers=headers, allow_redirects=False)
        #print (r)
        if r.status_code == 302:
            logging.info('Access token acquired')
            response_json = dict(
                    urllib.parse.parse_qsl(urllib.parse.urlparse(r.headers['Location']).fragment)
                )
            #print(response_json)
            #print(response_json['access_token'])
            return response_json['access_token']
        else:
            raise ValueError('Unable to login')

    except Exception as msg:
        logging.error(msg)

@rs38
Copy link
Contributor Author

rs38 commented Nov 26, 2020

I am also experiencing problems, but they also have some issues on the web login right now. I'm not able to login here: https://www.bmw-connecteddrive.de/app/index.html#/portal

@rs38
Copy link
Contributor Author

rs38 commented Nov 26, 2020

it turns out that my root cause issue since last weekend is that they need TLS 1.2 enabled.
Not sure how python deals with it, with .NET webclient it's ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants