Skip to content

feat(NZ): add browser-based OAuth auth for New Zealand - #1076

Draft
thesquib wants to merge 3 commits into
Hyundai-Kia-Connect:masterfrom
thesquib:feat/nz-browser-auth
Draft

feat(NZ): add browser-based OAuth auth for New Zealand#1076
thesquib wants to merge 3 commits into
Hyundai-Kia-Connect:masterfrom
thesquib:feat/nz-browser-auth

Conversation

@thesquib

@thesquib thesquib commented Apr 2, 2026

Copy link
Copy Markdown

The NZ Kia Connect signin endpoint (/api/v1/user/signin) uses TLS fingerprinting to reject non-browser HTTP clients. Python's requests library cannot authenticate NZ users via the standard password flow.

Changes:

  • KiaUvoApiAU.login(): raises AuthenticationError immediately for NZ with a message directing callers to use the browser-based flow
  • KiaUvoApiAU.get_authorize_url(): returns the OAuth authorize URL for the user to open in a browser
  • KiaUvoApiAU.login_with_auth_code(): exchanges a browser-obtained auth code for tokens, bypassing the fingerprinted signin endpoint; stores the raw OAuth refresh token so renewal works without re-authentication
  • KiaUvoApiAU.refresh_access_token(): overridden for NZ to use grant_type=refresh_token with the stored token rather than calling login() again
  • ApiImpl: adds get_authorize_url() and login_with_auth_code() stubs raising NotImplementedError for regions that don't use browser auth
  • VehicleManager: adds get_authorize_url() and login_with_auth_code() pass-throughs
  • _get_authorization_code_with_redirect_url(): adds mobileNum field to match what the NZ web app sends

Tested and confirmed working on a real NZ Kia Connect account.

thesquib and others added 3 commits April 3, 2026 11:31
The NZ Kia Connect signin endpoint (/api/v1/user/signin) uses TLS
fingerprinting to reject non-browser HTTP clients. Python's requests
library cannot authenticate NZ users via the standard password flow.

Changes:
- KiaUvoApiAU.login(): raises AuthenticationError immediately for NZ
  with a message directing callers to use the browser-based flow
- KiaUvoApiAU.get_authorize_url(): returns the OAuth authorize URL for
  the user to open in a browser
- KiaUvoApiAU.login_with_auth_code(): exchanges a browser-obtained auth
  code for tokens, bypassing the fingerprinted signin endpoint; stores
  the raw OAuth refresh token so renewal works without re-authentication
- KiaUvoApiAU.refresh_access_token(): overridden for NZ to use
  grant_type=refresh_token with the stored token rather than calling
  login() again
- ApiImpl: adds get_authorize_url() and login_with_auth_code() stubs
  raising NotImplementedError for regions that don't use browser auth
- VehicleManager: adds get_authorize_url() and login_with_auth_code()
  pass-throughs
- _get_authorization_code_with_redirect_url(): adds mobileNum field to
  match what the NZ web app sends

Tested and confirmed working on a real NZ Kia Connect account.
f"{self.__class__.__name__} does not support browser-based authentication"
)

def login_with_auth_code(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I am wondering if you found a better way to do the exact same thing EU has currently. Right now a script is used to get through a captcha on that one and grab the token and pass it in.

@cdnninja

cdnninja commented May 3, 2026

Copy link
Copy Markdown
Collaborator

Any chance the flow over in https://github.com/TMA84/bluelink-refresh-token also works for new zealand?

@cdnninja

Copy link
Copy Markdown
Collaborator

A new eu flow was just put in place. Could you check if the similar endpoints work for this?

@thesquib

thesquib commented May 19, 2026

Copy link
Copy Markdown
Author

Thanks I'll take a look as soon as I can (at both your comments above)

@cdnninja
cdnninja marked this pull request as draft May 24, 2026 21:20
@cdnninja

cdnninja commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

@thesquib Any thoughts on this? Should I close the PR?

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.

2 participants