Skip to content

fix nxapi hosted auth flow#80

Merged
cesaregarza merged 6 commits into
mainfrom
fix-nxapi-private-key-jwt
Mar 30, 2026
Merged

fix nxapi hosted auth flow#80
cesaregarza merged 6 commits into
mainfrom
fix-nxapi-private-key-jwt

Conversation

@cesaregarza

Copy link
Copy Markdown
Owner

Summary

This PR fixes the hosted nxapi authentication flow so the scraper can actually use a JWKS-backed client end to end.

What changed

  • added NXAPIClient support for generating fresh private_key_jwt client assertions from a PEM, jku, and kid
  • threaded generated-assertion config through config-file and environment loading
  • kept backward compatibility for legacy nxapi secret/env aliases
  • hardened hosted nxapi request handling, including a one-time fallback when a stale X-znca-Client-Version is rejected
  • updated the relevant tests and user-facing setup docs

Root cause

There were two separate runtime failures:

  1. the scraper could not authenticate a JWKS-backed nxapi client because it only accepted a prebuilt assertion string and did not generate private_key_jwt assertions itself
  2. after auth was fixed, the local config still carried a stale nxapi_client_version, which caused the hosted nxapi-znca-api service to reject the request with Invalid X-znca-Client-Version header

Validation

  • pytest -q tests/auth/test_nso.py tests/auth/test_nxapi_client.py tests/auth/tokens/test_constructor.py tests/auth/tokens/test_manager.py tests/query/configuration/test_config.py tests/query/configuration/test_config_option_handler.py
  • .venv/bin/pytest -q -m "not internet"
  • live nxapi-auth token request returned 200
  • live QueryHandler.from_config_file('.splatnet3_scraper').query('StageScheduleQuery') succeeded
  • live QueryHandler.from_config_file('.splatnet3_scraper').query('XRankingQuery') succeeded

Follow-up

A separate follow-up PR can tighten style and alignment with existing hand-crafted main conventions without mixing that cleanup into the functional fix.

@cesaregarza cesaregarza changed the title [codex] fix nxapi hosted auth flow fix nxapi hosted auth flow Mar 30, 2026
Comment thread tests/auth/test_nxapi_client.py Fixed
@sonarqubecloud

Copy link
Copy Markdown

@cesaregarza cesaregarza marked this pull request as ready for review March 30, 2026 05:03
@cesaregarza cesaregarza merged commit 5eb7bb7 into main Mar 30, 2026
4 checks passed
@cesaregarza cesaregarza deleted the fix-nxapi-private-key-jwt branch March 30, 2026 05:03
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