import { getUserData } from 'auth-worker'; import { useCallback, useEffect, useState } from 'react'; import './App.css'; const providerUrls: Record = { google: 'https://www.googleapis.com/oauth2/v3/userinfo', facebook: 'https://graph.facebook.com/v9.0/me', twitter: 'https://api.twitter.com/2/users/me?user.fields=profile_image_url', reddit: 'https://oauth.reddit.com/api/v1/me', auth0: 'https://dev-u8csbbr8zashh2k8.us.auth0.com/userinfo', }; function App() { const [result, setResult] = useState(null); useEffect(() => { if (!result) { getUserData().then(setResult as (data: unknown) => void, () => null); } }, []); const getUserInfo = useCallback(async () => { const userInfoUrl: string | null = result && providerUrls[result.provider]; if (userInfoUrl) { await fetch('/test'); const res = await fetch(userInfoUrl, { headers: { 'X-Use-Auth': 'true', }, }); const userInfo = await res.json(); console.log(userInfo); } }, [result]); return (
{result ? (

Logged in as {result.data.name}

Profile {JSON.stringify(result)} Logout
) : (
Log in with Google
Log in with Facebook
Log in with Twitter
Log in with Reddit
Log in with Auth0
)}
); } export default App;