Skip to content

Commit

Permalink
feat: 🎸 add facebook idToken
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian-potter committed Jul 10, 2024
1 parent 8b112f7 commit 55d747a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
32 changes: 13 additions & 19 deletions src/app/portkey-auth-callback/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,7 @@ export default function AuthCallback() {
const getToken = useCallback(() => {
try {
const { token, provider, code, message, idToken } = parseRedirectParams();
console.log(
token,
provider,
code,
message,
idToken,
" token, provider, code, message, idToken "
);

if (!window.Portkey)
throw "Timeout, please download and install the Portkey extension";
if (code) {
Expand All @@ -35,6 +28,7 @@ export default function AuthCallback() {
payload: {
response: {
access_token: token,
id_token: idToken,
provider,
},
},
Expand All @@ -46,17 +40,17 @@ export default function AuthCallback() {
}, []);

useEffect(() => {
// if (!window.Portkey) {
// const ids = setTimeout(() => {
// clearTimeout(ids);
// if (!window.Portkey)
// return setError(
// "Timeout, please download and install the Portkey extension"
// );
// getToken();
// }, 500);
// return;
// }
if (!window.Portkey) {
const ids = setTimeout(() => {
clearTimeout(ids);
if (!window.Portkey)
return setError(
"Timeout, please download and install the Portkey extension"
);
getToken();
}, 500);
return;
}
getToken();
}, [getToken]);
return (
Expand Down
4 changes: 2 additions & 2 deletions src/utils/parseRedirectParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const parseRedirectParams = (parseParam?: {
provider = "Google";
idToken = searchParams.id_token;
} else if (search) {
if (code && type !== "Facebook") {
if (code) {
errorMessage = message;
return { code, message: errorMessage };
}
Expand Down Expand Up @@ -112,7 +112,7 @@ export const parseRedirectParams = (parseParam?: {
});
}

provider = "Facebook";
provider = type;
} else if (authToken) {
token = JSON.stringify({
token: authToken,
Expand Down

0 comments on commit 55d747a

Please sign in to comment.