0.4.0 • Published 4 years ago
@openauth/google v0.4.0
Open Auth - Google
@openauth/google is an implementation of Google OAuth.
Installation
npm i @openauth/googleUsage
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')