-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Hyundai Kia: Refresh Token
This scripts helps owners of cars made by Hyundai or Kia to retrieve the
refresh_token that is now necessary to access the Bluelink API in the
integrations for HomeAssistant and evcc.
It is a combination of the separate efforts of @fuatakgun (original Kia implementation) and @Maaxion (Hyundai aption)
You need to have the following installed on your computer
Important
On Windows installations make sure to set the check at "Add Python 3.x to PATH" in the installer
- Python3 >= 3.12
-
wget(Linux/MacOS) oriwr(Windows) - Chrome or a Chromium based Brower
-
Copy the script from below to your local hard drive:
-
Linux/MacOS
wget -O bluelinktoken.py https://gist.github.com/RustyDust/e2a7be978affd85fb5ef5a345f31f67a/raw/3504e7f086be19caf182e208a4327ad841f5b1e7/bluelinktoken.py
-
Windows
Run inpowershell:iwr -UseBasicParsing -OutFile bluelinktoken.py https://gist.github.com/RustyDust/e2a7be978affd85fb5ef5a345f31f67a/raw/3504e7f086be19caf182e208a4327ad841f5b1e7/bluelinktoken.py
-
Linux/MacOS
-
Prepare the python runtime environment (you do have Python3 installed, right?)
-
Linux/MacOS
python3 -m venv .venv source .venv/bin/activate pip3 install selenium requests -
Windows
Do not double click the python file to run it. If you do, the terminal will close after the program ends, giving you no chance to copy the
refresh token.Open
cmdin the same dir you downloaded the Python file into (or continue in the powershell from the previous step):python -m venv .venv .\.venv\Scripts\Activate.ps1 python -m pip install --upgrade pip pip install selenium requests webdriver-manager
-
Note
You should still be in the Python environment from step 2.1 or 2.2 from above!
-
Linux/MacOS:
python ./bluelinktoken.py --brand kia
-
Windows:
python .\bluelinktoken.py --brand kia
-
Linux/MacOS:
python ./bluelinktoken.py --brand hyundai
-
Windows:
python .\bluelinktoken.py --brand hyundai
The script will automatically open your browser (you did install Chrome, yes?) with the correct URL for your vehicle's brand. Log in using the credentials (username / password) you use in the app on your mobile phone.
If everything worked as expected you'll get an output in your terminal similar to this:
Opening login page: https://idpconnect-eu.(kia/hyundai).com/auth/api/v2/user/oauth2/authorize?(...shortened...)
==================================================
Please log in manually in the browser window.
The script will wait for you to complete the login...
==================================================
✅ Login successful! Element found.
✅ Your tokens are:
- Refresh Token: M2M2OG................................YOTG5
- Access Token: eyJhbGc.........................0_AijpHXp0yg
Cleaning up and closing the browser.Use the Refresh Token from above as the password together with your normal
username when setting up either the HomeAssistant or evcc integration for your
vehicle.
Note
The refresh token you generated is valid for 180 days. After that period
you'll have to generate a new one and reconfigure your integrations