vue3-linkedin-login

Add Login With Linkedin feature to your Vue 3 app.
3,177 2
Install
npm install vue3-linkedin-login
Latest Version:0.1.8
Vue:3
Last Updated:Jul 15, 2023
Links: GitHub  ·  npm
Maintainer: devmustafakucuk

Vue3 Login with LinkedIn

This is a Vue3 package that provides a simple way to authenticate users with LinkedIn. It uses the LinkedIn OAuth2 protocol for user authentication and the LinkedIn API to retrieve the user's profile and other information.

Installation

npm install --save vue3-linkedin-login

We will trigger linkedInLogin by using useLinkedIn 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.

Usage

<template>
  <button @click="linkedInLogin">test</button>
</template>

<script setup>
  import { onMounted } from "vue";
  import { useLinkedIn, LinkedInCallback } from "vue3-linkedin-login";

  const { linkedInLogin, exchangeCodeForToken, getAccount, getMail } =
    useLinkedIn({
      clientId: "",
      clientSecret: "",
      redirectUri: "",
      onSuccess: async (code) => {
        const exchangeCode = await exchangeCodeForToken(code);
        const account = await getAccount(exchangeCode.access_token);
        const email = await getMail(exchangeCode.access_token);

        if (!account || !email) {
          return;
        }

        const firstName = account.localizedFirstName;
        const lastName = account.localizedLastName;
        const emailAddress = email.elements[0]["handle~"].emailAddress;

        const user = {
          firstName,
          lastName,
          emailAddress,
        };

        console.log(user);
      },
      scope: "r_emailaddress,r_liteprofile",
      onError: (error) => {
        console.log(error);
      },
    });

  onMounted(() => {
    LinkedInCallback();
  });
</script>

Props

Parameter Value Is Required Default
clientId string true -
clientSecret string true -
redirectUri string true -
onSuccess function true -
onError function true -
scope string true r_liteprofile
state string false -

This repo is inspired by the https://github.com/nvh95/react-linkedin-login-oauth2/ repo.

Related Packages

vue-advanced-cropper

The advanced library to create your own croppers suited for any website design

11,636,664 1,186
vue-google-oauth2

Handling Google Auth2 sign-in and sign-out

175,570 180
@authup/client-auth-console

Authup's hosted login, consent, registration, password recovery and device pages...

1,630 41
vue3-google-oauth2

Handling Google sign-in and sign-out for Vue3 applications.

141,765 56
@okta/okta-vue

Vue support for Okta

789,839 50

Version History

Version Released Vue License
0.1.8 ^3.0.0
0.1.7 ^3.0.0
0.1.6 ^3.0.0
0.1.5 ^3.0.0
0.1.4 ^3.0.0