Skip to content

fix(EU): update KIA/Hyundai authentication for new API endpoints#300

Merged
Hacksore merged 2 commits intoHacksore:masterfrom
dirkjanfaber:faberd/issue-295-eu-stopped-working
Aug 12, 2025
Merged

fix(EU): update KIA/Hyundai authentication for new API endpoints#300
Hacksore merged 2 commits intoHacksore:masterfrom
dirkjanfaber:faberd/issue-295-eu-stopped-working

Conversation

@dirkjanfaber
Copy link
Copy Markdown
Contributor

@dirkjanfaber dirkjanfaber commented Aug 8, 2025

KIA and Hyundai changed their EU authentication system, breaking existing login functionality with 401 Unauthorized errors. This implements the new authentication flow based on the updated API endpoints.

Changes:

  • Update authentication hosts: eu-account..com → idpconnect-eu..com
  • Update KIA client ID to new value (fdc85c00-0a2f-4c64-bcb4-2cfb1500730a)
  • Implement new 3-step OAuth2 flow with connector session keys
  • Remove language endpoint call that now requires pre-authentication
  • Update token exchange to use new idpconnect-eu endpoints
  • Remove unused imports and helper functions

The new authentication flow:

  1. GET auth URL to extract connector_session_key from redirect
  2. POST credentials to new signin endpoint with session key
  3. Extract authorization code from redirect location header
  4. Exchange code for tokens using new token endpoint

Fixes authentication issues for EU region KIA and Hyundai users.

Tested with KIA EU account - login, vehicle discovery, and status retrieval all working correctly.

Resolves issue #295

KIA and Hyundai changed their EU authentication system, breaking existing
login functionality with 401 Unauthorized errors. This implements the new
authentication flow based on the updated API endpoints.

Changes:
- Update authentication hosts: eu-account.*.com → idpconnect-eu.*.com
- Update KIA client ID to new value (fdc85c00-0a2f-4c64-bcb4-2cfb1500730a)
- Implement new 3-step OAuth2 flow with connector session keys
- Remove language endpoint call that now requires pre-authentication
- Update token exchange to use new idpconnect-eu endpoints
- Remove unused imports and helper functions

The new authentication flow:
1. GET auth URL to extract connector_session_key from redirect
2. POST credentials to new signin endpoint with session key
3. Extract authorization code from redirect location header
4. Exchange code for tokens using new token endpoint

Fixes authentication issues for EU region KIA and Hyundai users.

Tested with KIA EU account - login, vehicle discovery, and status retrieval
all working correctly.
@ndupont-net
Copy link
Copy Markdown
Contributor

Thanks a lot for that !
I tried to test it with this command, but I get very little files on node_modules/bluelinky. What is the best way to install it ?
npm install dirkjanfaber/bluelinky#10fb4d8a40ff0d4344e621ef814aae03ed8eac78

@PierreLevres
Copy link
Copy Markdown
Contributor

Good job. You were faster then me :)

Copy link
Copy Markdown
Contributor

@neoPix neoPix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this edit. I'm somewhat happy to see this old HTML parsing code go away.
I don't have the vehicle anymore, so I cannot test, but from a code perspective, it's ok 👍 .

@gruijter
Copy link
Copy Markdown
Contributor

@neoPix @Hacksore Can you pls bump the version and release it on NPM?

And would it be possible to also implement this PR on Bluelinky 8.3.0? Since that is the last version that runs on older Node12 (And I need that for older Homey devices).

Many thanks to everyone making this possible!!!

@Lazgar
Copy link
Copy Markdown

Lazgar commented Aug 10, 2025

If the release takes longer, is there a way to get an existing installation running again?

@PierreLevres
Copy link
Copy Markdown
Contributor

PierreLevres commented Aug 10, 2025 via email

@Lazgar
Copy link
Copy Markdown

Lazgar commented Aug 10, 2025

@PierreLevres I have no idea how to do that, could you maybe share the files here?

@neoPix
Copy link
Copy Markdown
Contributor

neoPix commented Aug 11, 2025

@neoPix @Hacksore Can you pls bump the version and release it on NPM?

Sadly, I don't have the authorizations on this repository 😞

What one can do in the meantime (requires some tech knowledges) :

  1. Pull the repo and use this branch.
  2. npm run build
  3. Copy whats in the folder /dist
    1. index.cjs and index.ems.js should be enough
  4. Paste it in the node_modules/bluelinky/dist of your code project
  5. It should work while waiting for the fix to be official.

@Hacksore
Copy link
Copy Markdown
Owner

This is on my radar and will get it released sometime soon.

@Hacksore
Copy link
Copy Markdown
Owner

Thanks @dirkjanfaber for the work here! LGTM and ill make a release for 10.0.0

@Hacksore Hacksore merged commit f45ed36 into Hacksore:master Aug 12, 2025
2 checks passed
@gruijter
Copy link
Copy Markdown
Contributor

Confirmed working for Kia EU. Thx everyone!

@ndupont-net
Copy link
Copy Markdown
Contributor

ndupont-net commented Aug 13, 2025

Confirmed too with my Niro, thanks @dirkjanfaber @Hacksore !
pi@node-pi:~/eNiro$ node eNiro Connecting to Kia API Client ready. Awaiting vehicle data. Login success Data retrieved properly. The file was saved!

@ghost
Copy link
Copy Markdown

ghost commented Aug 13, 2025 via email

@gerwim
Copy link
Copy Markdown

gerwim commented Aug 15, 2025

On Hyundai EU, this resulted for me in an error: clientSecret is wrong.

@gruijter
Copy link
Copy Markdown
Contributor

On Hyundai EU, this resulted for me in an error: clientSecret is wrong.

Hyundai EU reverted to the old endpoints. So use bluelunky v10 for Kia EU and v9 for Hyundai EU.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants