Redirect after Login takes me to dev-*****.okta.com instead of Application URL

I have a webpage, which is created on HTML/CSS and JavaScript. While Page loads, I place an API call to get User name and User Groups from (https://dev-.okta.com), if it fails I have coded in JavaScript to Redirect to dev-.Okta.com for login and get back to the webpage post authentication.

The problem is, the redirect do not work. Post login, and authentication, it takes me to dev-***.okta dashboard not to the webpage URL (I have a dev DNS name, so I use it instead of localhost).

I am new to Okta development and not sure what is it that I am doing is wrong.

If I was already logged in the browser and have a active session in https://dev-****.okta.com, then the page loads good with user name fetched and displayed properly.

I used the example from Add Authentication to Any Web Page in 10 Minutes | Okta Developer and used the widget API call to get the user details and user group.

And below is the JavaScript authentication to Okta redirect step I am following.

window.location.assign(‘https://dev-******.okta.com/oauth2/v1/authorize?redirect_uri=http://customdsn.organization.com:433’);

Any help here is much appreciated

How is you/your user currently logging into Okta? Were they created within Okta itself, or are they logging in through an external identity provider?

Also, quick note that the blog you are following is a bit dated. You may want to check out our newer, official guides: