Skip to content

Commit

Permalink
Atinux
Browse files Browse the repository at this point in the history
* refactor: userInfoURL from google provider to be configurable

* chore: rename to userURL

---------

Co-authored-by: Sébastien Chopin <[email protected]>
  • Loading branch information
brendonmatos and atinux authored Mar 22, 2024
1 parent 39ffaae commit 01dd56c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/runtime/server/lib/oauth/google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ export interface OAuthGoogleConfig {
*/
tokenURL?: string;

/**
* Google OAuth User URL
* @default 'https://www.googleapis.com/oauth2/v3/userinfo'
*/
userURL?: string;

/**
* Extra authorization parameters to provide to the authorization URL
* @see https://developers.google.com/identity/protocols/oauth2/web-server#httprest_3
Expand All @@ -63,6 +69,7 @@ export function googleEventHandler({
config = defu(config, useRuntimeConfig(event).oauth?.google, {
authorizationURL: 'https://accounts.google.com/o/oauth2/v2/auth',
tokenURL: 'https://oauth2.googleapis.com/token',
userURL: 'https://www.googleapis.com/oauth2/v3/userinfo',
authorizationParams: {}
}) as OAuthGoogleConfig
const { code } = getQuery(event)
Expand Down Expand Up @@ -119,7 +126,7 @@ export function googleEventHandler({

const accessToken = tokens.access_token
const user: any = await ofetch(
'https://www.googleapis.com/oauth2/v3/userinfo',
config.userURL as string,
{
headers: {
Authorization: `Bearer ${accessToken}`,
Expand Down

0 comments on commit 01dd56c

Please sign in to comment.