Skip to content

Commit

Permalink
code update
Browse files Browse the repository at this point in the history
  • Loading branch information
SamueleA committed Jan 17, 2025
1 parent 43a1075 commit 9bba4c4
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions packages/kit/src/components/ConnectButton/ConnectButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,25 @@ export const GoogleWaasConnectButton = (props: ConnectButtonProps) => {
const { connector, onConnect } = props
const storage = useStorage()

const getGoogleUserInfoAndLogin = async (access_token: string) => {
// TODO: Implement this on backend because of CORS
const userInfo = await fetch('https://www.googleapis.com/oauth2/v3/userinfo', {
headers: { Authorization: `Bearer ${access_token}` }
}).then(res => {
const credentials = '...'
storage?.setItem(LocalStorageKey.WaasGoogleIdToken, credentials)
onConnect(connector)
})
}
const login = useGoogleLogin({
onSuccess: credentialResponse => {
getGoogleUserInfoAndLogin(credentialResponse.access_token)
onSuccess: async response => {
// TODO: GET CREDENTIALS FROM BACKEND USING TOKENS
//https://github.com/MomenSherif/react-oauth/issues/12
const tokens = await fetch('http://localhost:3001/auth/google', {
method: 'POST',
body: JSON.stringify({ code: response.code })
})
// GET CREDENTIALS FROM BACKEND USING TOKENS
const credential = ''
storage?.setItem(LocalStorageKey.WaasGoogleIdToken, credential)
onConnect(connector)

console.log(tokens)
},
onError: () => {
console.log('Login Failed')
}
},
flow: 'auth-code'
})

const [enableGoogleTooltip, setEnableGoogleTooltip] = useState(false)
Expand Down

0 comments on commit 9bba4c4

Please sign in to comment.