huggingface / hub-docs

Docs of the Hugging Face Hub
http://hf.co/docs/hub
Apache License 2.0
289 stars 245 forks source link

Clarification Needed on Hugging Face OAuth Third-Party Login Implementation #1368

Closed NasaRocket closed 1 month ago

NasaRocket commented 2 months ago

Doc request

I am trying to implement a third-party login using Hugging Face's OAuth. Currently, the frontend is only able to obtain the values code=xxxx&state=xxxx. However, the documentation does not specify the subsequent steps needed to complete the authentication process. Could you please provide clarification on how to proceed after receiving these values? Here is the documentation link for reference: Hugging Face OAuth Documentation.

Additional context

It would be greatly helpful to have a step-by-step guide or example code on how to exchange the code for an access token and any other necessary steps to finalize the login process. Thank you!

julien-c commented 2 months ago

for @coyotte508 when he's back! or cc @Kakulukian too maybe

coyotte508 commented 1 month ago

Hello, we have some examples here: https://huggingface.co/docs/hub/spaces-oauth#examples

And the @huggingface/hub javascript library has support for oauth: https://github.com/huggingface/huggingface.js/tree/main/packages/hub#oauth-login. You can check https://github.com/huggingface/huggingface.js/blob/main/packages/hub/src/lib/oauth-login-url.ts and https://github.com/huggingface/huggingface.js/blob/main/packages/hub/src/lib/oauth-handle-redirect.ts for source implementation.

We basically follow openid connect standard, any open id client/oauth client should be able to log in via oauth. And on the backend we made sure to always send explicit error messages.

julien-c commented 1 month ago

can we close this @NasaRocket?

NasaRocket commented 1 month ago

ok