/** * HuggingFace OAuth2 provider for NextAuth v4. * Scopes: openid profile email repo:write read */ export default function HuggingFaceProvider(options) { return { id: "huggingface", name: "Hugging Face", type: "oauth", version: "2.0", authorization: { url: "https://huggingface.co/oauth/authorize", params: { scope: "openid profile email repo:write read", response_type: "code", }, }, token: "https://huggingface.co/oauth/token", userinfo: "https://huggingface.co/oauth/userinfo", clientId: options.clientId, clientSecret: options.clientSecret, profile(profile) { return { id: profile.sub, name: profile.name || profile.preferred_username || "HF User", email: profile.email, image: profile.picture, hfUsername: profile.preferred_username || profile.name, }; }, }; }