Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jpalumickas/node-oauth2-server-grant-type-facebook
https://github.com/jpalumickas/node-oauth2-server-grant-type-facebook
facebook node nodejs oauth oauth2 oauth2-server
Last synced: 16 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/jpalumickas/node-oauth2-server-grant-type-facebook
- Owner: jpalumickas
- License: mit
- Created: 2020-09-20T09:30:41.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-06-29T23:40:00.000Z (over 2 years ago)
- Last Synced: 2024-10-03T06:42:07.932Z (about 1 month ago)
- Topics: facebook, node, nodejs, oauth, oauth2, oauth2-server
- Language: TypeScript
- Homepage:
- Size: 251 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OAuth2 Server Facebook Grant Type
Adds Facebook grant type for [oauth2-server][oauth2-server]
## Installation
Using Yarn
```sh
yarn add oauth2-server-grant-type-facebook
```Using NPM
```sh
npm install oauth2-server-grant-type-facebook
```## Usage
Add `getUserWithFacebook` to [oauth2-server] model.
```js
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:
```js
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:
```js
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:
```json
{
"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](https://opensource.org/licenses/MIT).
[oauth2-server]: https://github.com/oauthjs/node-oauth2-server