Docs

Add Hugging Face as a social connection

You will learn the following:

  • Use Hugging Face to authenticate users with OAuth.

Enabling OAuth with Hugging Face allows your users to sign in and sign up to your Clerk application with their Hugging Face account.

Configure for your development instance

For development instances, Clerk uses preconfigured shared OAuth credentials and redirect URIs — no other configuration is needed.

To configure your development instance, follow these steps:

  1. Navigate to the Clerk Dashboard.
  2. In the top navigation, select Configure. Then in the sidebar, select SSO Connections.
  3. Select the Add connection button, and select For all users.
  4. In the Choose provider dropdown, select Hugging Face.
  5. Select Add connection.

Configure for your production instance

In production instances, you must provide custom credentials, which involves generating your own Client ID and Client Secret using your Hugging Face account.

To configure your production instance, follow these steps:

Create a Hugging Face Connected App

  1. Navigate to Hugging Face and sign in to your account.
  2. in the top right corner, select your avatar and select Settings.
  3. In the sidebar, select Connected Apps.
  4. Under Developer Applications, select Create App.
  5. Fill out the form as follows:
    • Application Name: Name the application whatever you'd like.
    • Homepage URL: Enter the homepage URL of your application.
    • Logo URL: Enter the URL of the logo for your application.
    • Token Expiration: Set the duration for which the token will be valid.
    • Scopes: Select the scopes that your application requires. Ensure that openid, profile, and email are included.
    • Redirect URLs: You will need to add the Redirect URI from Clerk. See the next step.

Get your Redirect URI from Clerk

  1. Navigate to the Clerk Dashboard.
  2. In the top navigation, select Configure. Then in the sidebar, select SSO Connections.
  3. Select the Add connection button, and select For all users.
  4. In the Choose provider dropdown, select Hugging Face.
  5. Ensure that both Enable for sign-up and sign-in and Use custom credentials are toggled on. Then, copy the Redirect URI.
  6. Navigate back to Hugging Face and paste the Redirect URI into the Redirect URLs field.
  7. Select Create application.

Set the Client ID and Client Secret in Clerk

  1. Once you have created your Hugging Face Connected App, copy the Client ID and App Secret.
  2. Navigate back to the Clerk Dashboard.
  3. In the Client ID and Client Secret field, paste the values you copied from Hugging Face.
  4. Select Add connection.

Test your OAuth

The simplest way to test your OAuth is to visit your Clerk application's Account Portal, which is available for all Clerk applications out-of-the-box.

  1. In the navigation sidebar of the Clerk Dashboard, select Account Portal.
  2. Next to the Sign-in URL, select Visit. The URL should resemble:
  3. On the sign-in page, you should see Hugging Face as an option. Use it to sign in with your Hugging Face account.

Feedback

What did you think of this content?

Last updated on