Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Okta Authentication, Cannot GET /implicit/callback

I'm following this guide https://developer.okta.com/quickstart/ to add authentication to my React App. I've set everything as per the guide, and I get the id token from the demo preview site. The log says the authentication is successful and provides an id token back. This is how the redirect looks like.

On the redirect I get this error: Cannot GET /implicit/callback displayed in the browser. Where did I go wrong?

This is how my index.js looks like in React:

import { Security, SecureRoute, ImplicitCallback } from '@okta/okta-react';

ReactDOM.render((
  <HashRouter>
    <Switch>
        <Security issuer={config.issuer}
                  client_id={config.clientId}
                  redirect_uri={config.redirect_uri} >
            <Route path='/' exact={true} component={Full}/>
            <Route path='/implicit/callback' component={ImplicitCallback} />
        </Security>
    </Switch>
  </HashRouter>
), document.getElementById('root'));

I think it might have something to do with HashRouter and CoreUI but I don't know what exactly is the problem as I can get it running with the normal create-react-app template.

like image 880
Salmaan P Avatar asked Nov 11 '17 00:11

Salmaan P


People also ask

What is Okta login callback?

LoginCallback handles the callback after the redirect to and back from the Okta-hosted login page. By default, it parses the tokens from the uri, stores them, then redirects to / . If a SecureRoute caused the redirect, then the callback redirects to the secured route.


1 Answers

It was an issue with Webpack. Setting devServer.historyApiFallback: true and output.publicPath: '/' in webpack config fixed the issue.

HashRouter still didn't work, had to use BrowserRouter.

like image 157
Salmaan P Avatar answered Sep 19 '22 13:09

Salmaan P