1.0.6 • Published 6 months ago

@neogeek/create-app-oauth-providers v1.0.6

Weekly downloads
-
License
-
Repository
github
Last release
6 months ago

@neogeek/create-app-oauth-providers

Tests NPM version

Install

$ npm install @neogeek/create-app-oauth-providers

Usage

import { google } from '@neogeek/create-app-oauth-providers';

import {
  GoogleOAuthProfileResponseSchema,
  GoogleOAuthTokenResponseSchema,
} from '@neogeek/create-app-oauth-providers/dist/providers/google';

(async () => {
  const code = req.query.code;

  const tokens = await google.getTokens(code, {
    client_id: process.env.GCP_OAUTH_CLIENT_ID,
    client_secret: process.env.GCP_OAUTH_CLIENT_SECRET,
    redirect_uri: process.env.GCP_OAUTH_REDIRECT_URL,
  });

  const validatedTokens = GoogleOAuthTokenResponseSchema.parse(tokens);

  const profile = await google.getProfile(tokens.access_token);

  const validatedProfile = GoogleOAuthProfileResponseSchema.parse(profile);

  console.log({ tokens, profile });
})();

Types

import type {
  GoogleOAuthProfileResponse,
  GoogleOAuthTokenResponse,
} from '@neogeek/create-app-oauth-providers/dist/providers/google';

Schema (zod validation)

import {
  GoogleOAuthProfileResponseSchema,
  GoogleOAuthTokenResponseSchema,
} from '@neogeek/create-app-oauth-providers/dist/providers/google';
1.0.6

6 months ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago