Have ideas to improve npm?Join in the discussion! »

simple-social-signin
TypeScript icon, indicating that this package has built-in type declarations

1.0.9 • Public • Published

Simple Social Signin

Simple social sign in for Node.js

Usage

Google

  1. Import
import { getGoogleAuthUri, getGoogleUserInfo } from 'simple-social-signin';
  1. Get auth URI
const authUri = getGoogleAuthUri({
    clientId: 'a client ID',
    redirectUri: 'https://example.com/my-google-callback',
});  // Send this to the browser for the user to open
  1. Get user info
console.log(await getGoogleUserInfo({
    code: 'code URL query you get at /my-google-callback',
    clientId: 'a client ID',
    clientSecret: 'a client secret',
    redirectUri: 'https://example.com/my-google-callback'
}));
{
  email: '...',
  family_name: '...',
  gender: '...',
  given_name: '...',
  hd: '...',
  id: '...',
  link: '...',
  locale: '...',
  name: '...',
  picture: '...',
  verified_email: boolean,
  token: {
      access_token: '...',
      refresh_token: '...',
      scope: '...',
      token_type: '...',
      id_token: '...',
      expires_in: '...',
      created_at: '...',
  }
}

Facebook

  1. Import
import { getFacebookAuthUri, getFacebookUserInfo } from 'simple-social-signin';
  1. Get auth URI
const authUri = getFacebookAuthUri({
    clientId: 'a client ID',
    redirectUri: 'https://example.com/my-google-callback',
    state: 'a random string'
});
  1. Get user info
console.log(await getFacebookUserInfo({
    code: 'code URL query you get at /my-google-callback',
    clientId: 'a client ID',
    clientSecret: 'a client secret',
    redirectUri: 'https://example.com/my-facebook-callback'
}));
{
    email: '...',
    id: '...',
    first_name: '...',
    middle_name: '...',
    last_name: '...',
    short_name: '...',
    name: '...',
    name_format: '...',
    picture: {
        data: {
            height: 123,
            is_silhouette: boolean,
            url: '...',
            width: 321
        }
    }
}

Dependencies

  • Superagent HTTP lib

Keywords

none

Install

npm i simple-social-signin

DownloadsWeekly Downloads

1

Version

1.0.9

License

MIT

Unpacked Size

32.3 kB

Total Files

9

Last publish

Collaborators

  • avatar