Docs

OAuth with LinkedIn Open ID Connect (OIDC)

You will learn the following:

  • Use LinkedIn OIDC to authenticate users with OAuth.

Configure for your development instance

To make the development flow as smooth as possible, Clerk uses preconfigured shared OAuth credentials and redirect URIs for development instances - no other configuration is needed. Navigate to the Clerk Dashboard and go to User & Authentication -> Social Connections. In the list of Auth Providers, enable LinkedIn and select Save.

Configure for your production instance

In production instances, you must provide custom credentials, which includes generating your own Client ID and Client Secret using your LinkedIn Developer account. Don't worry, this tutorial will walk you through that process in just a few steps.

Tip

If you already have a LinkedIn app you'd like to connect to Clerk, select your app from the LinkedIn Developer Portal and skip to the next step in this tutorial.

  1. On the homepage of the LinkedIn Developer Portal, select Create app. You'll be taken to the Create an app form.
  2. Fill out the form as follows:
    1. Under App name, name the application whatever you'd like. "Clerk Demo App", for example.
    2. Under LinkedIn Page, paste the URL of the LinkedIn page you'd like to associate with the application.
    3. Under App logo, upload an image to represent the application.
    4. Under Legal agreement, select the checkbox to agree to LinkedIn's API Terms of Use.
    5. Finally, select Create app.

Get your client ID and client secret

Once your LinkedIn app is created, you'll be taken to the app's dashboard.

  1. Select the Auth tab.
  2. Under Application credentials, you'll find your Client ID and Primary Client Secret. Copy these values and save them somewhere secure, as they are required to connect your LinkedIn app to your Clerk app.
  3. Keep this page open, as you'll need to come back to it in a moment.

Connect your LinkedIn app and get your redirect URI

  1. In another tab, visit the Clerk Dashboard.
  2. In the navigation sidebar, go to User & Authentication > Social Connections.
  3. In the list of Auth Providers, enable LinkedIn.
  4. Ensure that both Enable for sign-up and sign-in and Use custom credentials are toggled on. Then:
    1. Under Client ID, add the value you copied from Client ID in the LinkedIn dashboard.
    2. Under Client Secret, add the value you copied from Primary Client Secret in the LinkedIn dashboard.
    3. Copy the Authorized redirect URI. You need it to configure your LinkedIn app.
    4. Select Save.

Set the Authorized Redirect URI for your LinkedIn application

  1. Navigate back to the LinkedIn Developer Portal and go to the Auth tab.
  2. Under the OAuth 2.0 settings section, next to Authorized redirect URLs for your app, select the Edit icon.
  3. Select Add redirect URL and add the Authorized redirect URI you copied from the Clerk Dashboard.

Enable OpenID Connect in your LinkedIn application

  1. Select the Products tab.
  2. Next to Sign In with LinkedIn using OpenID Connect, select Request access.

Note

If you need to ensure the longevity of the user's access token without the need for re-authentication, make sure to obtain approval as a Marketing Developer Platform (MDP) partner. This is not required if you don't directly interact with the LinkedIn API using the access token.

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 Continue with LinkedIn as an option. Use it to sign in with your LinkedIn account.

Feedback

What did you think of this content?