oauth2-server-grant-type-facebook
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

OAuth2 Server Facebook Grant Type

Adds Facebook grant type for oauth2-server

Installation

Using Yarn

yarn add oauth2-server-grant-type-facebook

Using NPM

npm install oauth2-server-grant-type-facebook

Usage

Add getUserWithFacebook to oauth2-server model.

  const getUserWithFacebook = async (facebookData) => {
    // Find and return user by Facebook ID

    // Find and return user by Facebook email

    // If not exists create new user
  };

Add Facebook grant type to extendedGrantTypes in oauth2-server options:

  import FacebookGrantType from 'oauth2-server-grant-type-facebook';

  const options = {
    model: ...,
    extendedGrantTypes: {
      facebook: FacebookGrantType,
    }
    requireClientAuthentication: {
      facebook: false,
    },
  }

You can customize what fields to return from Facebook by providing facebookGrantType options in model:

const options = {
  model: {
    ...model,
    facebookGrantType: {
      fields: ['email', 'first_name', 'last_name', 'picture.width(500).height(500)'], // Default: email, first_name, last_name
    }
  }
}

Post request to /oauth/token with facebook grant type:

{
  "grant_type": "facebook",
  "client_id": "YOUR_CLIENT_ID",
  "facebook_token": "FACEBOOK_TOKEN"
}

License

The package is available as open source under the terms of the MIT License.

/oauth2-server-grant-type-facebook/

    Package Sidebar

    Install

    npm i oauth2-server-grant-type-facebook

    Weekly Downloads

    1

    Version

    0.3.0

    License

    MIT

    Unpacked Size

    38.4 kB

    Total Files

    13

    Last publish

    Collaborators

    • jpalumickas