Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jpalumickas/node-oauth2-server-grant-type-google
https://github.com/jpalumickas/node-oauth2-server-grant-type-google
google node nodejs oauth oauth2 oauth2-server
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/jpalumickas/node-oauth2-server-grant-type-google
- Owner: jpalumickas
- License: mit
- Created: 2020-09-20T15:43:07.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-10-23T23:48:23.000Z (3 months ago)
- Last Synced: 2024-10-26T08:55:24.919Z (3 months ago)
- Topics: google, node, nodejs, oauth, oauth2, oauth2-server
- Language: TypeScript
- Homepage:
- Size: 262 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 Google Grant Type
Adds Google grant type for [oauth2-server][oauth2-server]
## Installation
Using Yarn
```sh
yarn add oauth2-server-grant-type-google
```Using NPM
```sh
npm install oauth2-server-grant-type-google
```## Usage
Add `getUserWithGoogle` to [oauth2-server] model.
```js
const getUserWithGoogle = async (googleData) => {
// Find and return user by Google ID// Find and return user by Google email
// If not exists create new user
};
```Add Google grant type to `extendedGrantTypes` in [oauth2-server] options:
```js
import GoogleGrantType from 'oauth2-server-grant-type-google';const options = {
model: ...,
extendedGrantTypes: {
google: GoogleGrantType,
}
requireClientAuthentication: {
google: false,
},
}
```You need to provide Google Client ID in model `googleGrantType` :
```js
const options = {
model: {
...model,
googleGrantType: {
clientId: 'xxxxxxx.apps.googleusercontent.com' // Array also supported
},
},
extendedGrantTypes,
}
```Post request to `/oauth/token` with `google` grant type and provided id token:
```json
{
"grant_type": "google",
"client_id": "YOUR_CLIENT_ID",
"google_id_token": "GOOGLE_ID_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