I am setting Okta auth for a client using React and Node.js and I am getting the following. After providing credentials in okta login screen on our dev environment, the user is redirected to implicit/callback
url and token
HTTPS request gets the following error:
- error: “invalid_client”
- error_description: “Client authentication failed. Either the client or the client credentials are invalid.”
The login flow works well in local
environment and I am able to access everything but when we deploy to our dev
we get error above even though our clientId
and oktaDomain credentails
On top of this, if I get this error, I don’t see any way to redirect the user to a different screen from the implicit/callback
which is not ideal. All we are getting is the page below.
Below is the code we are using. API Access Management feature is enabled.
Can someone assist?
const config = {
issuer: `https://${process.env.REACT_APP_OKTA_DOMAIN}/oauth2/default`,
redirectUri: window.location.origin + '/implicit/callback',
clientId: process.env.REACT_APP_CLIENT_ID,
// pkce => false in local and dev because it requires HTTPS. it's true for testing and prod.
pkce: process.env.NODE_ENV !== 'development',
}
export const routes = (
<ConnectedRouter history={history}>
<Switch>
<Security {...config}>
<Route
exact
path={CmsRoutes.Home}
component={oktaAuth(withOkta(Dashboard))} />
<Route path="/implicit/callback" component={ImplicitCallback} />
// ...
</Security>
</Switch>
</ConnectedRouter>
)