/** *
( options: OAuthUserConfig
): OAuthConfig
{ return { id: "tiktok", name: "TikTok", type: "oauth", authorization: { url: "https://www.tiktok.com/v2/auth/authorize", params: { client_key: options.clientId, scope: "user.info.profile", response_type: "code", }, }, token: { async request({ params, provider }) { const res = await fetch(`https://open.tiktokapis.com/v2/oauth/token/`, { method: "POST", headers: { "Cache-Control": "no-cache", "Content-Type": "application/x-www-form-urlencoded", }, body: new URLSearchParams({ client_key: provider.clientId!, client_secret: provider.clientSecret!, code: params.code!, grant_type: "authorization_code", redirect_uri: provider.callbackUrl!, }), }).then((res) => res.json()) const tokens: TokenSet = { access_token: res.access_token, expires_at: res.expires_in, refresh_token: res.refresh_token, scope: res.scope, id_token: res.open_id, token_type: res.token_type, session_state: res.open_id, } return { tokens, } }, }, userinfo: { url: "https://open.tiktokapis.com/v2/user/info/?fields=open_id,avatar_url,display_name,username", async request({ tokens, provider }) { return await fetch(provider.userinfo?.url as URL, { headers: { Authorization: `Bearer ${tokens.access_token}` }, }).then(async (res) => await res.json()) }, }, profile(profile) { return { id: profile.data.user.open_id, name: profile.data.user.display_name, image: profile.data.user.avatar_url, email: profile.data.user.email || null, } }, style: { bg: "#000", text: "#fff", }, options, } }