mirror of
https://github.com/penxio/penx.git
synced 2026-01-13 07:27:57 -05:00
30 lines
602 B
TypeScript
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
|
|
}
|