@openauth/google
TypeScript icon, indicating that this package has built-in type declarations

0.4.0 • Public • Published

Open Auth - Google

Downloads Version License Typescript dependencies Status

@openauth/google is an implementation of Google OAuth.

Installation

npm i @openauth/google

Usage

import { GoogleOAuth } from '@openauth/google'

const oauth = new GoogleOAuth({
  clientId: 'client_id',
  clientSecret: 'client_secret',
  redirectUri: 'https://wani.kr/auth/google/callback',
  scope: [
    'email',
    'profile',
    'openid',
  ],
})

// 1. After getting auth request uri, connect.
const redirectUri = await oauth.getAuthRequestUri()

// 2. It redirects with the code, and replaces the access token with this code value.
const { accessToken } = await oauth.getAccessTokenResponse(code)

// 3. Get user profile.
await oauth.getAuthUser(accessToken)

// 4. Other API
await oauth.getClient(accessToken).get('oauth2/v3/userinfo')

Package Sidebar

Install

npm i @openauth/google

Weekly Downloads

108

Version

0.4.0

License

MIT

Unpacked Size

11.4 kB

Total Files

15

Last publish

Collaborators

  • wan2land