Repository navigation
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
kohbanye
force-pushed
the
fix-access-token-refresh-margin
branch
from
October 26, 2026 09:09
dccfde7 to
4080300
Compare
access_token_has_expired() subtracted its 30-minute margin from the current time, so a token counted as expired only 30 minutes after its expiration. During that window get_access_token() returned the expired token and every API call failed with 401. Add the margin instead, so the token is refreshed 30 minutes before it expires. Fixes Kaggle#74
kohbanye
force-pushed
the
fix-access-token-refresh-margin
branch
from
October 26, 2026 09:12
4080300 to
fe71d9a
Compare
kohbanye
marked this pull request as ready for review
October 26, 2026 09:21
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
KaggleCredentials.access_token_has_expired()subtracts its 30-minute margin from the current time:This is true only once the token has been expired for more than 30 minutes. For the first 30 minutes after expiry,
get_access_token()keeps returning the expired token. Every API call then fails with HTTP 401, and the kaggle CLI prints "Authentication required to call the Kaggle API." Meanwhilekaggle auth loginreports "You are already logged-in". The failure clears itself 30 minutes later.This change adds the margin instead, so the token is refreshed 30 minutes before it expires. The margin is now a named constant,
ACCESS_TOKEN_REFRESH_MARGIN.Needs manual sync with the kapigen base.
Fixes #74. Also reported in Kaggle/kaggle-cli#1217.
Verification
Ran
kaggle competitions listwith kaggle 2.2.4 against the live API, using a~/.kaggle/credentials.jsonwhoseaccess_token_expirationwas set to 10 minutes in the past:access_token_expirationis 12 hours later) and the command printed the competition list.