Authenticated returning null - Users are created but can't log in due to lack of authentication

I am relatively new to okta. I am using okta for custom login with the help of the tutorial here https://developer.okta.com/blog/2018/02/06/build-user-registration-with-node-react-and-okta.

I noticed New users are created and logged in but not authenticated. Since authenticated returns null, It makes it impossible to route to the profile page. It only redirects to to http://localhost:3000/login#id_token=eyJr… and the page goes blank without routing to the user profile pge.

I am thinking the problem is with “authenticated” returning null. That is the line of code pasted below which must return true if the user is to be routed to the users profile page.

    async checkAuthentication() {
	   const authenticated = await this.props.auth.isAuthenticated();
		if(authenticated !== this.state.authenticated) {
			this.setState( {authenticated} );
		}
	}

I have seriously checked for typos in my code but didn’t find any.

Although I noticed something strange. My redirect_url in my ap.config.js code reads window.location.origin+'/implicit/callback', but I was getting a 400 code error redirect to my okta page with an error of The ‘redirect_uri’ parameter must be an absolute URI that is whitelisted in the client app settings.

I later noticed that my redirect link parameter in the address bar (on the 400page) has “/login” in it (even when I didn’t expect it to). below is the part I extracted from the address bar on my okta 400page.

http://…redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Flogin&response…

So, I had to whitelist http://localhost:3000/login in the client app settings before it could successfully redirect. But now, it won’t authenticate and I have tried all possible solution but none worked.

Please I will be glad to get help and know where else I need to check at this point. Thanks in advance for any help rendered.

I got it fixed.

I had to check all files all over again only to realise I actually wrote “redirect_url” in my index.js file and app.configure.js. Really, I thought it was correct until I went to check the tutorial again only to realise it’s actually “redirect_uri”.

After the correction, the strange redirect Url having “login” also changed and I didn’t need to whitelist any Url again except the default “http:localhost:3000/implicit/callback”.

Everything is back to normal and my app works fine with no errors now.

Thanks Okta.

2 Likes