Skip to content
This repository has been archived by the owner on Sep 21, 2023. It is now read-only.

Login fails when third-party cookies are disabled #238

Open
sourcesync opened this issue Jul 24, 2019 · 2 comments
Open

Login fails when third-party cookies are disabled #238

sourcesync opened this issue Jul 24, 2019 · 2 comments

Comments

@sourcesync
Copy link

If you disable third-party cookies, then the login fails with this error:

fail

Apparently many people have this setting by default and don't even know it.

The only solution seems to be a server-side authentication flow. Any work-arounds ?

google/google-api-javascript-client#260

@thecmdrunner
Copy link

Still no workaround for this?

@MylesWardell
Copy link

A workaround.

You wont get google profile infomation but you will get an auth token that validates on the backend. From this the backend request can get firstName, lastName, email, profileImage ect. I got tipped off when I saw a site work with 3rd party cookies disabled using redirectUri which adds this information via queryParams so it should be possible using uxMode="redirect" as well.

  const [token, setToken] = useState<string>()

  useEffect(() => {
    const handleAuthMessage = ({ data }) => {
      try {
        const responseObject = JSON.parse(data)
        if (responseObject?.method === 'fireIdpEvent') {
          setToken(responseObject?.params?.authResult?.id_token)
        }
      } catch (error) {
        return
      }
    }

    window.addEventListener('message', handleAuthMessage)

    return () => {
      window.removeEventListener('message', handleAuthMessage)
    }
  }, [])

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants