@neogeek/create-app-oauth-providers
$ npm install @neogeek/create-app-oauth-providers
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 });
})();
import type {
GoogleOAuthProfileResponse,
GoogleOAuthTokenResponse,
} from '@neogeek/create-app-oauth-providers/dist/providers/google';
import {
GoogleOAuthProfileResponseSchema,
GoogleOAuthTokenResponseSchema,
} from '@neogeek/create-app-oauth-providers/dist/providers/google';