Skip to content

Commit

Permalink
Update frontend OktaCallback component and api calls to work with new…
Browse files Browse the repository at this point in the history
… python endpoints
  • Loading branch information
nickviola committed Sep 17, 2024
1 parent 7420674 commit e1428fa
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions frontend/src/pages/OktaCallback/OktaCallback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import { useAuthContext } from 'context';
import { User } from 'types';
import { useHistory } from 'react-router-dom';

type OktaCallbackResponse = {
token: string;
user: User;
};
type OktaCallbackResponse = any;
// {
// body: any;
// // user: User;
// };

export const OktaCallback: React.FC = () => {
const { apiPost, login } = useAuthContext();
Expand All @@ -16,8 +17,6 @@ export const OktaCallback: React.FC = () => {
const handleOktaCallback = useCallback(async () => {
const { code } = parse(window.location.search);
console.log('Code: ', code);
const nonce = localStorage.getItem('nonce');
console.log('Nonce: ', nonce);

try {
// Pass request to backend callback endpoint
Expand All @@ -26,17 +25,21 @@ export const OktaCallback: React.FC = () => {
{
body: {
code: code
},
headers: {
'Content-Type': 'application/json'
}
}
);
console.log('Response: ', response);
console.log('token ', response.token);

console.log('Response: ', response.body);
console.log('token ', response.body.token);
const nonce = localStorage.getItem('nonce');
console.log('Nonce: ', nonce);
// Login
await login(response.token);

login(response.token);
// Storage Management
localStorage.setItem('token', response.token);
localStorage.setItem('token', response.body.token);
localStorage.removeItem('nonce');
localStorage.removeItem('state');

Expand Down

0 comments on commit e1428fa

Please sign in to comment.