Skip to content

[Auth] Take google colab token from env first#4323

Merged
Wauplin merged 1 commit into
mainfrom
google-colab-token-from-env-first
Jun 8, 2026
Merged

[Auth] Take google colab token from env first#4323
Wauplin merged 1 commit into
mainfrom
google-colab-token-from-env-first

Conversation

@Wauplin

@Wauplin Wauplin commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Originally from @xenova on slack (internal):

Raising as potential unexpected behaviour. The team were making model changes via colab, and even though they logged in, it seemed to have picked the colab secret instead.

This PR fixes this. If a user runs login in a Colab (saves the token in a local file) or sets an env variable, it should take precedence over the Colab's vault.


Note

Medium Risk
Changes authentication precedence in Google Colab, which can alter which HF account is used for hub requests when multiple token sources exist.

Overview
Reorders HF token resolution in Colab so explicit user credentials win over the notebook secrets vault.

get_token() now checks HF_TOKEN / HUGGING_FACE_HUB_TOKEN, then the on-disk token file (e.g. after login()), and only then Google Colab’s HF_TOKEN secret. Previously Colab’s vault was consulted first, which could override a token the user had just saved via login() or set in the environment.

Reviewed by Cursor Bugbot for commit e3e2a9b. Bugbot is set up for automated code reviews on this repo. Configure here.

@Wauplin Wauplin requested a review from hanouticelina June 8, 2026 10:24

@julien-c julien-c left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

kinda makes sense

@bot-ci-comment

bot-ci-comment Bot commented Jun 8, 2026

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@Wauplin Wauplin merged commit b60b6da into main Jun 8, 2026
25 of 26 checks passed
@Wauplin Wauplin deleted the google-colab-token-from-env-first branch June 8, 2026 10:48
@huggingface-hub-bot

Copy link
Copy Markdown
Contributor

This PR has been shipped as part of the v1.19.0 release.

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