Repository navigation
Conversation
A callable access_token is now attached to the session as a requests AuthBase (BearerTokenAuth) and called on every outgoing request, instead of being sent once at session start. A token provider (e.g. an OAuth client) can refresh the token before it expires, without a 401 or a new TM1 session. TM1py stays headless: obtaining, refreshing and storing the token is left to the caller. String tokens behave as before (sent at session start, then dropped). A callable that returns an empty token raises ValueError. Tested against PAaaS (TM1 12.6.4) through PAW's /api/v1/tm1/<db> route: refreshing the token mid-run needs no reconnect and keeps the same TM1 session.
This branch has not been deployed
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.
Summary
access_tokencan now be a callable. TM1py attaches it to the session as arequestsAuthBase(BearerTokenAuth) and calls it on every request, so a caller's token provider can refresh the token before it expires: no 401, no reconnect, no new TM1 session.TM1py stays headless: getting, refreshing and storing tokens is left to the caller. This replaces the approach in #1488/#1494/#1495 (reconnect-based refresh,
keep_authorization_header, browser sign-in, local listener, token storage inside TM1py).String tokens behave as before. A callable that returns an empty token raises
ValueError.Changes
RestService:BearerTokenAuth, used whenaccess_tokenis callable; docstring entry foraccess_tokenTests/RestService_access_token_test.py: offline tests with a patched adapter: per-request token, refresh without reconnect, 401 retry, async polling, threads, unchanged string-token behaviourTests/RestService_oauth_test.py: live tests, skipped without an[oauth]section inconfig.ini(eitheraccess_token, or refresh settings); documented inconfig.ini.templateTested
PAaaS, TM1 12.6.4, via
https://<PawHost>/api/v1/tm1/<db>:Observed:
🤖 Generated with Claude Code