Repository navigation
Conversation
allozaur
force-pushed
the
allozaur/feat/hf-oauth-sign-in
branch
from
November 20, 2026 23:08
abfbd5d to
78ef997
Compare
allozaur
force-pushed
the
allozaur/feat/hf-oauth-sign-in
branch
from
November 23, 2026 12:03
e9ed2f1 to
d763f55
Compare
allozaur
force-pushed
the
allozaur/feat/hf-conversation-sharing
branch
from
November 23, 2026 12:05
440d772 to
ca7c30b
Compare
allozaur
force-pushed
the
allozaur/feat/hf-oauth-sign-in
branch
2 times, most recently
from
November 24, 2026 17:37
ba8d5fc to
9f91b89
Compare
allozaur
force-pushed
the
allozaur/feat/hf-oauth-sign-in
branch
from
November 24, 2026 18:57
9f91b89 to
d94b69b
Compare
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.
Overview
The Share to Hugging Face dialog gets a "Sign in with Hugging Face" button, so a trace can be shared without creating and pasting an access token. Token sign-in stays next to it.
Demo
Recorded at 9f91b89; click the preview for the full video.
Additional information
Stacked on ggml-org#32608 (
allozaur/feat/hf-conversation-sharing).Checked against huggingface.co without signing in: one dynamic client registration with the redirect
http://192.168.1.5:8080/?hf_oauth=1and scopeopenid profile write-repos manage-reposwas accepted as asked (201, public client, all four scopes). The authorization URL with that client and redirect goes on to the login page, while one with a redirect the client was not registered for gets a 400, so a LAN origin works. That probe used the earlier scopes; the sign-in now asks forcontribute-reposinstead. A full sign-in with an account onlocalhost, with that scope, and a share with the token it gives are in the demo above. Not checked: whether a dataset one browser's sign-in created can be written from another browser, since each registers its own client.Known gap: the popup, callback and BroadcastChannel handling mirrors the MCP browser sign-in (fork PR #63) instead of sharing code with it; both move to one OAuth util once both land.
How it works
/oauth/register) and CORS on its token and registration endpoints, so it all runs in the browser, with no server and no client secret.httploopback hosts may change port), and llama-server runs on any host and port, so a fixed app registration would only coverlocalhost. Instead the app registers itself as a public client (token_endpoint_auth_method: none) for its own origin's root,/?hf_oauth=1, and keeps the client ID for the next sign-in from that origin.openid profile contribute-repos: the app can create datasets and write only to the ones it created, so the consent page no longer asks to manage every repository. Tokens that come back withoutcontribute-reposare refused with a message. A client registered for other scopes registers again, and a share to a dataset the sign-in may not write to (a 403) says to pick a new dataset name or use an access token.same-origin, so the popup cannot reach its opener: the page load that comes back trades the code for tokens and announces the result on a BroadcastChannel; the dialog then checks the account withwhoami-v2as with a token.statedoes not match a pending sign-in from this browser (or is older than 15 minutes) is ignored; the callback parameters are cleared from the address before the exchange, so a reload cannot repeat it.What changed
HfOAuthService: stateless client: redirect URL, PKCE pair, state, registration, authorization URL, code exchange, refresh, write-scope check.huggingFaceStore:signInWithHuggingFace(popup),completeSignInFromLocation(),cancelSignInWithHf(),authMethod,isSigningInWithHf,oauthError; token refresh before a share; the pasted-tokensignInis unchanged for the dialog.DialogConversationShare: the button, a "finish signing in on the Hugging Face page" note with Cancel, the OAuth error, and "or use an access token" above the existing form. The read-only token warning applies to pasted tokens only.Testing
In
ui/apps/chat:npm run check,npm run lintand the unit tests pass.hf-oauth-service.test.ts(mocked fetch): the RFC 7636 PKCE test vector, the registration body, a refused registration and an unreachable Hub, the authorization URL, the code exchange body and tokens, a refused code, refresh keeping the refresh token, the write-scope check.hf-traces-service.test.tsadds the 403 message.hf-oauth-sign-in.svelte.test.ts(browser, mocked Hub): a popup sign-in through towhoami-v2, reusing the registered client, a forgedstate, a refused registration pointing to token sign-in, tokens without write access, a cancelled sign-in, refreshing an expired token, sign-out keeping the client.error=access_deniedand a pending sign-in clears the address and the pending sign-in and shows "The sign-in was cancelled.".Demo script
Recorded with a person at the keyboard for the sign-in (#130):
DEMO_GITHUB_REPO=allozaur/llama.cpp DEMO_HEADED=1 npm run demo:pr -- 92. The share is real: it creates a public dataset on the account that signs in.Requirements
Claude (Opus 5.5 Medium)