wallet-svr/src/providers/facebook.provider.ts
2023-08-23 19:07:08 +08:00

20 lines
888 B
TypeScript

import { NetClient } from 'net/NetClient'
const FACEBOOK_API_HOST = 'https://graph.facebook.com'
export const FACEBOOK_APP_ID = '1204701000119770'
const FACEBOOK_APP_SECRET = '5a1deba64b30c7326f497fc52691207f'
export async function getAppAccessToken() {
const url = `${FACEBOOK_API_HOST}/oauth/access_token?client_id=${FACEBOOK_APP_ID}&clent_secret=${FACEBOOK_APP_SECRET}&grant_type=client_credentials`
return new NetClient().httpGet(url)
}
export async function verifyFbUserAccessToken(accessToken: string) {
const url = `${FACEBOOK_API_HOST}/debug_token?input_token=${accessToken}&access_token=GG|${FACEBOOK_APP_ID}|${FACEBOOK_APP_SECRET}`
return new NetClient().httpGet(url)
}
export async function fetchUserInfo(accessToken: string) {
const url = `${FACEBOOK_API_HOST}/me?fields=["email","id", "name"]&access_token=${accessToken}`
return new NetClient().httpGet(url)
}