Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

supplying both google's access_token & github's code

Blue Mouse94c6551b046f
diff --git a/src/pages/Auth/Socialised/index.tsx b/src/pages/Auth/Socialised/index.tsx
index 732d91c52..fb9fb0acb 100644
--- a/src/pages/Auth/Socialised/index.tsx
+++ b/src/pages/Auth/Socialised/index.tsx
@@ -4,9 +4,11 @@ import React, {
import { Link } from 'react-router-dom'
import { useTranslation } from 'react-i18next'
import { CheckCircleIcon, XCircleIcon } from '@heroicons/react/24/solid'
+import _split from 'lodash/split'
import _replace from 'lodash/replace'
import { processSSOToken } from 'api'
+import { SSO_PROVIDERS } from 'redux/constants'
import Title from 'components/Title'
import Loader from 'ui/Loader'
import routes from 'routes'
@@ -25,19 +27,34 @@ const Socialised = (): JSX.Element => {
const { searchParams } = new URL(_location)
const hash = searchParams.get('state')
- const token = searchParams.get('access_token')
-
- console.log(hash, token)
+ const accessToken = searchParams.get('access_token')
+ const code = searchParams.get('code')
+ const provider = _split(hash, ':')[0]
useEffect(() => {
const processCode = async () => {
- if (!token || !hash) {
+ if (!hash || !provider) {
+ setIsError(true)
+ return
+ }
+
+ let _token
+
+ if (provider === SSO_PROVIDERS.GOOGLE) {
+ _token = accessToken
+ }
+
+ if (provider === SSO_PROVIDERS.GITHUB) {
+ _token = code
+ }
+
+ if (!_token) {
setIsError(true)
return
}
try {
- await processSSOToken(token, hash)
+ await processSSOToken(_token, hash)
} catch (reason) {
setIsError(true)
console.error(`[ERROR] Error while processing Google code: ${reason}`)