-
Notifications
You must be signed in to change notification settings - Fork 202
Kia Europe Login Flow
Kia has recently made some changes to its login flow, which currently means that a Google reCAPTCHA must be solved during login. It is not currently possible to solve this automatically with python, which is why manual steps are necessary here.
Python scripts have been developed for this purpose, which take over at least part of the process of obtaining the necessary refresh_token, which must then be used as a password.
The procedure varies depending on the operating system and environment. However, we will document all variants here where possible so that every end user should be able to create their own personal refresh_token.
If you have any questions or need assistance, please review and utilize only this discussion.
See this issue if you are interested in more background information.
NEVER EVER publish your refresh token or access token. If someone gets them, they will have full access to your Kia account and thus also to your car! No email address or password is required!
If you have access to a headless Linux via SSH, e.g., a Raspberry Pi, LXC, KVM, etc., you can use this option. This requires a few manual steps.
It is important that you use Chrome or one of its forks (Chromium, Brave, etc.), as the user agent can be changed there without an add-on.
Without setting the specific user agent, it is not possible to obtain the refresh_token!
Now to the procedure:
- Download this script
- Execute the script with python
- Follow the instructions in the script
- Save the refresh token (preferably in your password database as well)
- Enter the refresh token, instead of your Kia password, in the password field
Here is the procedure again as an example:
$ mkdir /tmp/kia && cd /tmp/kia
$ wget -O KiaFetchApiTokens.py https://gist.githubusercontent.com/marvinwankersteen/af92c571881ac76579a037fac4f3a63a/raw/8f59b802dce728dc547d3c012fadc86878ceceba/KiaFetchApiTokens.py
$ python3 KiaFetchApiTokens.py
Step 1: Open your Browser new (best is Chrome), CTRL+SHIFT+I, CTRL-SHIFT+P, type 'network conditions', uncheck 'Use browser default' and set the following user-agent:
Mozilla/5.0 (Linux; Android 4.1.1; Galaxy Nexus Build/JRO03C) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19_CCS_APP_AOS
Step 2: Open this URL:
https://idpconnect-eu.kia.com/auth/api/v2/user/oauth2/authorize?ui_locales=de&scope=openid+profile+email+phone&response_type=code&client_id=peukiaidm-online-sales&redirect_uri=https%3A%2F%2Fwww.kia.com%2Fapi%2Fbin%2Foneid%2Flogin&state=aHR0cHM6Ly93d3cua2lhLmNvbS9kZS8
Step 3: Solve the reCAPTCHA and login with your credentials. After successful login, you get redirected to Kia's homepage.
Was the login successful? (y/n): y
Fetch the connector_session_key...successful.
Step 4: Open the following URL in the SAME browser tab where you're logged in:
https://idpconnect-eu.kia.com/auth/api/v2/user/oauth2/authorize?client_id=fdc85c00-0a2f-4c64-bcb4-2cfb1500730a&redirect_uri=https://prd.eu-ccapi.kia.com:8080/api/v1/user/oauth2/redirect&response_type=code&scope=&state=ccsp&connector_client_id=hmgid1.0-fdc85c00-0a2f-4c64-bcb4-2cfb1500730a&ui_locales=&connector_scope=&connector_session_key=f8761a96-10c8-41e6-80a6-75c265904c24
Step 5: A blank page will open with the URL from step 4 which starts with 'https://prd.eu-ccapi.kia.com:8080/api/v1/user/oauth2/redirect?code=...'
Copy the full URL from the address bar and paste it here:
> https://prd.eu-ccapi.kia.com:8080/api/v1/user/oauth2/redirect?code=9785a908-............-67706072d32d&state=ccsp&login_success=y
✅ Your tokens are:
- Refresh Token: NTBIO.................................UWMJI3ZJZJ
- Access Token: eyJhbGciOi.......................WI2iqczsxKq-dKKg
If you have Linux with a graphical user interface (Ubuntu Desktop, Linux Mint, Rasperry Pi, etc.), you can also use the Selenium version, which automates most of the steps.
- Download this script
- Prepare environment and execute the script with python
- Follow the instructions in the script
- Save the refresh token (preferably in your password database as well)
- Enter the refresh token, instead of your Kia password, in the password field
Here is the procedure again as an example:
$ mkdir /tmp/kia && cd /tmp/kia
$ wget -O KiaFetchApiTokensSelenium.py https://gist.github.com/fuatakgun/fa4ef1e1d48b8dca2d22133d4d028dc9/raw/fe95ed7c02913f6277878a100458be78b794603d/gistfile1.txt
$ python3 -m venv .venv
$ source .venv/bin/activate
$ pip3 install selenium requests
$ python3 KiaFetchApiTokensSelenium.py
Opening login page: https://idpconnect-eu.kia.com/auth/api/v2/user/oauth2/authorize?ui_locales=de&scope=openid%20profile%20email%20phone&response_type=code&client_id=peukiaidm-online-sales&redirect_uri=https://www.kia.com/api/bin/oneid/login&state=aHR0cHM6Ly93d3cua2lhLmNvbTo0NDMvZGUvP21zb2NraWQ9MjM1NDU0ODBmNmUyNjg5NDIwMmU0MDBjZjc2OTY5NWQmX3RtPTE3NTYzMTg3MjY1OTImX3RtPTE3NTYzMjQyMTcxMjY=_default
==================================================
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.