Files
penx/apps/web/lib/getGoogleUserInfo.ts
0xzio 3edfe1aebf refactor: use monorepo
fix: fix build

chore: update README

feat: init extension

fix: fix web build
2025-04-19 01:48:59 +08:00

30 lines
602 B
TypeScript

export interface GoogleUserInfo {
email: string
email_verified: boolean
picture: string
sub: string
name: string
}
export async function getGoogleUserInfo(
accessToken: string,
): Promise<GoogleUserInfo> {
const response = await fetch(
'https://www.googleapis.com/oauth2/v3/userinfo',
{
method: 'GET',
headers: {
Authorization: `Bearer ${accessToken}`,
Accept: 'application/json',
},
},
)
if (!response.ok) {
throw new Error('Network response was not ok')
}
const data = await response.json()
return data as GoogleUserInfo
}