diff --git a/packages/better-auth/src/plugins/generic-oauth/index.ts b/packages/better-auth/src/plugins/generic-oauth/index.ts index 15a8e5cad3..5bf1de1845 100644 --- a/packages/better-auth/src/plugins/generic-oauth/index.ts +++ b/packages/better-auth/src/plugins/generic-oauth/index.ts @@ -24,11 +24,6 @@ interface GenericOAuthConfig { * If provided, the authorization and token endpoints will be fetched from this URL. */ discoveryUrl?: string; - /** - * Type of OAuth flow. - * @default "oauth2" - */ - type?: "oauth2" | "oidc"; /** * URL for the authorization endpoint. * Optional if using discoveryUrl. @@ -116,10 +111,9 @@ interface GenericOAuthOptions { async function getUserInfo( tokens: OAuth2Tokens, - type: "oauth2" | "oidc", finalUserInfoUrl: string | undefined, ) { - if (type === "oidc" && tokens.idToken) { + if (tokens.idToken) { const decoded = parseJWT(tokens.idToken) as { payload: { sub: string; @@ -145,6 +139,7 @@ async function getUserInfo( sub?: string; name: string; email_verified: boolean; + picture: string; }>(finalUserInfoUrl, { method: "GET", headers: { @@ -155,6 +150,7 @@ async function getUserInfo( id: userInfo.data?.sub, emailVerified: userInfo.data?.email_verified, email: userInfo.data?.email, + image: userInfo.data?.picture, ...userInfo.data, }; } @@ -418,11 +414,7 @@ export const genericOAuth = (options: GenericOAuthOptions) => { const userInfo = ( provider.getUserInfo ? await provider.getUserInfo(tokens) - : await getUserInfo( - tokens, - provider.type || "oauth2", - finalUserInfoUrl, - ) + : await getUserInfo(tokens, finalUserInfoUrl) ) as User | null; if (!userInfo?.email) {