hugging-c-ai / src /lib /providers /huggingface.js
NeoPy's picture
feat: Hugging-c-ai v2 — HF OAuth + multi-provider AI + HF bucket storage + Gradio
60faa09
Raw History Blame Contribute Delete
909 Bytes
/**
* 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,
};
},
};
}