Skip to content

OAuth providers

Hugging Face

HuggingFace.provider adds Sign in with Hugging Face to an OAuth strategy. The preset is for sign-in only; it does not retain provider API access.

Create an OAuth application and register https://app.example.com/auth/huggingface/callback. See Sign in with Hugging Face.

apps/server/huggingface.ts
import { Config, Effect, Layer } from "effect";
import { Http, HuggingFace } from "@yielded/auth";
import { AppAuth } from "./auth";
export const AuthRoutes = Layer.unwrap(
Effect.gen(function* () {
return Http.layer(AppAuth, {
origin: yield* Config.String("APP_ORIGIN"),
oauth: {
providers: {
huggingface: HuggingFace.provider({
clientId: yield* Config.String("HUGGINGFACE_CLIENT_ID"),
clientSecret: yield* Config.Redacted("HUGGINGFACE_CLIENT_SECRET"),
scopes: ["openid", "profile", "email"],
}),
},
},
});
}),
);

Supply HTTP, crypto, persistence and application services. The durable identity is (provider key, "https://huggingface.co", verified sub). Declare profiles: { huggingface: HuggingFace.HuggingFaceUserProfile } for typed providerData. Use a distinct callback for this provider.

Run the Hugging Face application with APP_ORIGIN, HUGGINGFACE_CLIENT_ID, HUGGINGFACE_CLIENT_SECRET, HUGGINGFACE_USER_ID, SESSION_KEY, and OAUTH_TRANSACTION_KEY. Register /auth/huggingface/callback on an HTTPS origin forwarded to 127.0.0.1:3000.

vp run @yielded/example-auth#example:huggingface

Open APP_ORIGIN/login. See the example setup for key and storage ownership.