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
- Python3 >= 3.12
- git
- Chrome or a Chromium based Brower
- Copy the script to your local hard drive
- Using
git clonegit clone https://github.com/RustyDust/bluelink_refresh_token.git cd bluelink_refresh_token - Using the command line
- Linux/MacOS
wget -O bluelinktoken.py https://raw.githubusercontent.com/RustyDust/bluelink_refresh_token/refs/heads/main/bluelinktoken.py
- Windows
Run inpowershell:iwr -UseBasicParsing -OutFile bluelinktoken.py https://raw.githubusercontent.com/RustyDust/bluelink_refresh_token/refs/heads/main/bluelinktoken.py
- Linux/MacOS
- Using
- 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
python -m venv .venv .\.venv\Scripts\Activate.ps1 python -m pip install --upgrade pip pip install selenium requests webdriver-manager
- Linux/MacOS
Note
You should still be in the Python environment from step 2.1 or 2.2 from above!
- Linux:
python3 -/bluelinktoken.py --brand kia
- Windows:
python .\bluelinktoken.py --brand kia
- Linux:
python3 -/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