All Projects → nvh95 → react-linkedin-login-oauth2

nvh95 / react-linkedin-login-oauth2

Licence: MIT license
Easily get Authorization Code from Linked In to log in without redirecting.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to react-linkedin-login-oauth2

Socialite
Socialite is an OAuth2 Authentication tool. It is inspired by laravel/socialite, you can easily use it without Laravel.
Stars: ✭ 1,026 (+1136.14%)
Mutual labels:  oauth, login, linkedin
Oauth
🔗 OAuth 2.0 implementation for various providers in one place.
Stars: ✭ 336 (+304.82%)
Mutual labels:  oauth, login, linkedin
Login With
Stateless login-with microservice for OAuth
Stars: ✭ 2,301 (+2672.29%)
Mutual labels:  oauth, login, linkedin
Play Pac4j
Security library for Play framework 2 in Java and Scala: OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 375 (+351.81%)
Mutual labels:  oauth, login
Express Stormpath
Build simple, secure web applications with Stormpath and Express!
Stars: ✭ 327 (+293.98%)
Mutual labels:  oauth, login
verdaccio-github-oauth-ui
📦🔐 GitHub OAuth plugin for Verdaccio
Stars: ✭ 56 (-32.53%)
Mutual labels:  oauth, login
supabase-ui-svelte
Supabase authentication UI for Svelte
Stars: ✭ 83 (+0%)
Mutual labels:  oauth, login
Simplicity
A simple way to implement Facebook and Google login in your iOS apps.
Stars: ✭ 683 (+722.89%)
Mutual labels:  oauth, login
Yii2 Authclient
Yii 2 authclient extension.
Stars: ✭ 430 (+418.07%)
Mutual labels:  oauth, linkedin
Authing
🔥Authing - IDaaS/IAM solution that can Auth to web and mobile applications.
Stars: ✭ 247 (+197.59%)
Mutual labels:  oauth, login
Nemiro.oauth.dll
Nemiro.OAuth is a class library for authorization via OAuth protocol in .NET Framework
Stars: ✭ 45 (-45.78%)
Mutual labels:  oauth, login
Spring Webmvc Pac4j
Security library for Spring Web MVC: OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 110 (+32.53%)
Mutual labels:  oauth, login
oauth
Allow users to log in with GitHub, Twitter, Facebook, and more!
Stars: ✭ 21 (-74.7%)
Mutual labels:  oauth, linkedin
appleauth-net
AppleAuth.NET is a simple library that facilitates the implementation of "Sign in with Apple" for .NET applications.
Stars: ✭ 23 (-72.29%)
Mutual labels:  oauth, signin
Turnstile
An authentication framework for Swift.
Stars: ✭ 163 (+96.39%)
Mutual labels:  oauth, login
Buji Pac4j
pac4j security library for Shiro: OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 444 (+434.94%)
Mutual labels:  oauth, login
jax-rs-pac4j
Security library for JAX-RS and Jersey
Stars: ✭ 48 (-42.17%)
Mutual labels:  oauth, login
oauth2-wechat
微信登录认证授权 Wechat login authorization. This package provides Wechat OAuth 2.0 support for the PHP League's OAuth 2.0 Client
Stars: ✭ 18 (-78.31%)
Mutual labels:  oauth, login
Play Authenticate
An authentication plugin for Play Framework 2.x (Java)
Stars: ✭ 813 (+879.52%)
Mutual labels:  oauth, linkedin
Spark Pac4j
Security library for Sparkjava: OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 154 (+85.54%)
Mutual labels:  oauth, login

React Linked In Login Using OAuth 2.0

react-linkedin-login-oauth2 VERSION 2 IS OUT. THIS IS MIGRATION GUIDE FROM 1 TO 2.

All Contributors PRs Welcome

npm package npm

Demo: https://stupefied-goldberg-b44ee5.netlify.app/

This package is used to get authorization code for Linked In Log in feature using OAuth2 in a easy way. After have the authorization code, you can exchange to an access token by sending it to the server to continue to get information needed. For more details, please see at Authorization Code Flow (3-legged OAuth)
See Usage and Demo for instruction.

Table of contents

Changelog

See CHANGELOG.md

Installation

npm install --save react-linkedin-login-oauth2@latest

Overview

We will trigger linkedInLogin by using useLinkedIn (recommended) or LinkedIn (using render props technique) after click on Sign in with LinkedIn button, a popup window will show up and ask for the permission. After we accepted, the pop up window will redirect to redirectUri (should be LinkedInCallback component) then notice its opener about the authorization code Linked In provides us. You can use react-router-dom or Next.js's file system routing

Usage

First, we create a button and provide required props:

import React, { useState } from 'react';

import { useLinkedIn } from 'react-linkedin-login-oauth2';
// You can use provided image shipped by this package or using your own
import linkedin from 'react-linkedin-login-oauth2/assets/linkedin.png';

function LinkedInPage() {
  const { linkedInLogin } = useLinkedIn({
    clientId: '86vhj2q7ukf83q',
    redirectUri: `${window.location.origin}/linkedin`, // for Next.js, you can use `${typeof window === 'object' && window.location.origin}/linkedin`
    onSuccess: (code) => {
      console.log(code);
    },
    onError: (error) => {
      console.log(error);
    },
  });

  return (
    <img
      onClick={linkedInLogin}
      src={linkedin}
      alt="Sign in with Linked In"
      style={{ maxWidth: '180px', cursor: 'pointer' }}
    />
  );
}

If you don't want to use hooks. This library offer render props option:

import React, { useState } from 'react';

import { LinkedIn } from 'react-linkedin-login-oauth2';
// You can use provided image shipped by this package or using your own
import linkedin from 'react-linkedin-login-oauth2/assets/linkedin.png';

function LinkedInPage() {
  return (
    <LinkedIn
      clientId="86vhj2q7ukf83q"
      redirectUri={`${window.location.origin}/linkedin`}
      onSuccess={(code) => {
        console.log(code);
      }}
      onError={(error) => {
        console.log(error);
      }}
    >
      {({ linkedInLogin }) => (
        <img
          onClick={linkedInLogin}
          src={linkedin}
          alt="Sign in with Linked In"
          style={{ maxWidth: '180px', cursor: 'pointer' }}
        />
      )}
    </LinkedIn>
  );
}

Then we point redirect_url to LinkedInCallback. You can use react-router-dom or Next.js's file system routing

  • react-router-dom:
import React from 'react';
import { LinkedInCallback } from 'react-linkedin-login-oauth2';

import { BrowserRouter, Route } from 'react-router-dom';

function Demo() {
  return (
    <BrowserRouter>
      <Route exact path="/linkedin" component={LinkedInCallback} />
    </BrowserRouter>
  );
}
  • Next.js's file system routing:
// pages/linkedin.js
import { LinkedInCallback } from 'react-linkedin-login-oauth2';
export default function LinkedInPage() {
  return <LinkedInCallback />;
}

Support IE

  • Support for IE is dropped from version 2

Demo

Props

  • LinkedIn component:
Parameter value is required default
clientId string yes
redirectUri string yes
onSuccess function yes
onError function no
state string no randomly generated string (recommend to keep default value)
scope string no 'r_emailaddress'
See your app scope here. If there are more than one, delimited by a space
children function no Require if using LinkedIn component (render props)

Reference: https://docs.microsoft.com/en-us/linkedin/shared/authentication/authorization-code-flow?context=linkedin/context#step-2-request-an-authorization-code

  • LinkedInCallback component:
    No parameters needed

Issues

Please create an issue at https://github.com/nvh95/react-linkedin-login-oauth2/issues. I will spend time to help you.

Failed to minify the code from this file: ./node_modules/react-linkedin-login-oauth2/node_modules/query-string/index.js:8

Please upgrade react-linkedin-login-oauth2 to latest version following

npm install --save react-linkedin-login-oauth2

Known issue

Contributors

Thanks goes to these wonderful people (emoji key):


Hung Viet Nguyen

💻

Nguyễn Duy Khánh

💻

YBeck

💻

Mehdi Raza

🤔

Phillip Denness

🐛

dsp.iam

🐛

Vitalii Bulyzhyn

💻

Pradeep Reddy Guduru

🐛

Uric Bonatti Cardoso

🐛

faisalur-rehman

📖

Ruslan

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].