Platform

Sign Up With LinkedIn

10min

Sign In with LinkedIn Tutorial

Introduction

Sign In with LinkedIn enables users to sign in to Apps using their LinkedIn accounts.

Prerequisites

To complete this tutorial, you will need:

1 - Create a New Back4App App

First of all, it’s necessary to make sure that you have an existing app created at Back4App. However, if you are a new user, you can check this tutorial to learn how to create one.

2 - Create a new LinkedIn App

Log into your LinkedIn Developer account click Create App and choose OAuth client ID

Document image


Choose an App name and fill in the required fields such as Business email and App logo. Agree to the terms and click Create app

Document image


In your newly created App, click Verify to verify the ownership of the App. You must be the owner or administrator of the LinkedIn page to verify.

Document image


In the Verification page, click Generate URL

Document image


Visit the generated Verification URL using the admin or owner account of the company’s page on LinkedIn.

Document image


Click on Approve Verification

Document image


Make sure your App is verified

Document image


In your App, go to the Auth tab, fill in the Redirect URLs field, and click Update

Document image


3 - Retrieve your Code

Visit the following URL, changing the values for CLIENT_ID, REDIRECT_URL, and A_RANDOM_STRING for the ones you created. The random string is to avoid CSRF attacks.

https://www.linkedin.com/oauth/v2/authorization?response_type=code&client_id=CLIENT_ID&redirect_uri=REDIRECT_URL&state=A_RANDOM_STRING&scope=r_emailaddress

Log in with your LinkedIn account and the redirected website will have your code in the URL:

Document image


Copy the Code part of the URL only and run the following CURL command replacing the values YOUR_CODE, YOUR_CLIENT_ID, YOUR_CLIENT_SECRET, and YOUR_REDIRECT_URI for the values of your application

Curl


Run it and you should retrieve your access token:

REMEMBER: the code can be used only once. If you get an error or don’t use your token, you must re-generate your Code to be able to run it again.

4 - Start the development

Now that the Sign-in with LinkedIn is configured, you can start the development process. The format for AUTHDATA is:

JSON


Here is the method for the iOS SDK:

Swift


And here for the Android SDK:

Java