feat: Replace BasicAuth with OAuth2 client credentials flow#867
Open
leewc wants to merge 1 commit into
Open
Conversation
OpenSky Network dropped basic authentication on March 18, 2026 and now exclusively uses OAuth2 client credentials. This updates the authenticate() method to accept client_id and client_secret instead of BasicAuth, with automatic token refresh. OAuth2 state (credentials + token + expiry) is bundled into a private _OAuthSession dataclass to keep the OpenSky instance attribute count at 8, matching pre-OAuth2. Ref: openskynetwork/opensky-api#85 Ref: home-assistant/core#156643
Author
|
^ Tried adding labels but it appears I do not have permissions to.. this is an enhancement/new feature. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Firstly -- Thank you for making this repo and open source. I use it for home assistant because I didn't want to set up my own software defined antenna.
OpenSky Network dropped basic authentication on March 18, 2026 and now exclusively uses OAuth2 client credentials. This updates the authenticate() method to accept client_id and client_secret instead of BasicAuth, with automatic token refresh. (API docs).
Currently,
python-openskyusesaiohttp.BasicAuthinauthenticate(), which means authenticated requests no longer work. Anonymous access still functions but with reduced rate limits (400 credits/day, 15-minute resolution).OAuth2 state (credentials + token + expiry) is bundled into a private _OAuthSession dataclass to keep the OpenSky instance attribute count at 8, matching pre-OAuth2.
Ref: openskynetwork/opensky-api#85
Ref: home-assistant/core#156643
Proposed Changes
BasicAuthwith OAuth2 client credentials token exchangehttps://auth.opensky-network.org/auth/realms/opensky-network/protocol/openid-connect/tokenauthenticate()acceptsclient_idandclient_secretinstead ofBasicAuthRelated Issues
Additional disclosure
AI was used in the crafting of this PR, however, I personally validated the code and tested it.
Testing Done
Live Integration Test (2026-06-07)
(Note: Once this is merged I can test the HA integration itself)
Test Script
Save as
integration_test.pyand run from the repo root withuv run python integration_test.py. Authenticated section runs only ifOPENSKY_CLIENT_IDandOPENSKY_CLIENT_SECRETare set.Output (live OpenSky API, Seattle bounding box)
Observations
https://auth.opensky-network.org/auth/realms/opensky-network/protocol/openid-connect/tokenreturns access token; library transitionsis_authenticatedFalse → True/api/states/allrequest usesAuthorization: Bearer <token>header (replaces removed BasicAuth)remaining_credits()returns 3998 — bounding box query costs 1 credit and is counted twice in this test (once in the authenticate roundtrip, once in the explicitget_statescall). Matches expected behavior.Local Quality Gates