my site stuck at this point ,not opening my secure routes
(making single page React website)
Hello! Are you seeing any errors in the console? And/or any errors in your Okta system logs?
No, console is clear
I think this is not commpatible with latest version of react-route-dom as there are some major changes in latest version .
i am new to okta please hlep
successfully got response but unable to redirect anywhere
So you’re getting tokens back from /token but then just hanging on the callback URL? Can you post your configured routes?
import { Switch, Route,useHistory } from “react-router-dom”;
import { Box } from “@material-ui/core”;
import “./App.css”;
import Header from “./components/Header”;
import Home from “./components/home/Home”;
import DetailView from “./components/posts/DetailView”;
import CreateView from “./components/posts/CreateView”;
import UpdateView from “./components/posts/UpdateView”;
import Login from ‘./components/account/Login’;
import { Security, SecureRoute, LoginCallback } from ‘@okta/okta-react’;
import { OktaAuth, toRelativeUrl } from ‘@okta/okta-auth-js’;
import { oktaAuthConfig, oktaSignInConfig } from ‘./config’;
const oktaAuth = new OktaAuth(oktaAuthConfig);
function AppWithRouterAccess() {
const history = useHistory();
const customAuthHandler = () => {
history.push('/login');
};
const restoreOriginalUri = async (_oktaAuth, originalUri) => {
history.replace(toRelativeUrl(originalUri, window.location.origin));
};
return (
<>
<Security
oktaAuth={oktaAuth}
onAuthRequired={customAuthHandler}
restoreOriginalUri={restoreOriginalUri}
>
<SecureRoute path='/' exact={false} component={Header} />
<Box style={{ marginTop: 64 }}>
<Switch>
<Route exact path='/' component={Home} />
<Route
path="/login"
render={() => <Login config={oktaSignInConfig} />}
/>
<Route path="/login/callback" component={LoginCallback} />
<Route exact path="/details/:id" component={DetailView} />
<Route exact path="/create" component={CreateView} />
<Route exact path="/update/:id" component={UpdateView} />
</Switch>
</Box>
</Security>
</>
);
}
export default AppWithRouterAccess;
this is my AppWithRouterAccess.js file
finally it is sorted.
i think there was a bug from okta which they resolved successfully.
now i am able to redirect( )
Just match your laptop/pc date with internet time
Hi
I am trying to implement okta auth.
My App.js has the login component which direct to okta login widget. Upon successful authentication I am getting redirect to ‘/main’ where I have a Appbar component followed by some routes. My Appbar has the Link which will use useHistory hook to push the respective path to the url. But I am not able to see the components when I click those Links in the Appbar. Url is changing, but I can only see Appbar.
Here is the return JSX of Appbar
<>
Appbar/>
Switch/>
Route path="/drafts" component={Drafts} exact />
Route path="/dashboard" component={Dashboard} exact />
/Switch>
</>
Can someone help me in this?
What was the fix??? It would be helpful for many others I suspect.
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.