GithubHelp home page GithubHelp logo

linkedin-oauth-helper's Introduction

linkedin-oauth-helper

This is a helper script to handle LinkedIn OAuth. For a detailed, step-by-step guide, please refer to this article I wrote. If you found this repository useful, please consider giving it a star โญ on GitHub. This helps to promote the project and show your support.

How it works

The script check if there's a valid access token in a local json file. If it exists, it uses it to do an API call to get the corresponding user ID. If the API call is successful, it prints both: the user access token & ID &. If it fails, it starts the OAuth process by executing the following steps:

  • It builds the authorization url
  • It launches the default user's browser and redirect it to the previously built authorization url to handle the authorization process.
  • The user will have to log in &/or proceed by allowing access.
  • Once user proceeds, the script will handle the callback where authorization code is sent (using a minimalist express server).
  • Once the script gets the authorization code, it uses it to do 2 API requests: get an access token and the corresponding user ID. Once finished, it saves the access token to a local file, and prints the result to the browser & the console.

Requirements

Before using this script, make sure to copy the env.example file to .env. Once you've done that, you need to create a LinkedIn app and get the client id and secret, and then update the .env file with these variables. You can do it here: https://www.linkedin.com/developer/apps

Note: please make sure to have the same REDIRECT_URI value configured in both LinkedIn app's page and this script

Installation

Execute the following command to install the required dependencies: npm install

Usage

Simply execute the following command: node index.js

Output

Once the script is finished, you should see the following output:

Console:

{
linkedInId: '***.....',
linkedInAccessToken: '*************************.....'
}

Browser:

Your can now close this window. :-)
linkedInId	linkedInAccessToken
***.....  	*************************.....

Customization:

  • You can customize the redirect url in the .env file
  • You can customize the file where the access token is saved in the .env file

linkedin-oauth-helper's People

Contributors

azizfcb avatar

Stargazers

 avatar Erik Hunter avatar Emmanuel Odenyire Anyira avatar Nishant Maheshwari avatar Mohammed Rashid avatar Federico U avatar abraham avatar yubin avatar FAHED YASIN avatar  avatar Robi Alfaro Ballena avatar  avatar

Watchers

 avatar Kostas Georgiou avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.