After login with microsoft login redirect to mydomain.com/app/userhome

Hello everybody,

From the developer console, I made a custom sign-in page. I have added a login button from the Mircosoft. It does work, but after login, I am being redirected to https://mydomain.com/app/userhome. Is there a way to change this. Here is the code I used:

<title>{{pageTitle}}</title>
{{{SignInWidgetResources}}}
<!--
    "OktaUtil" defines a global OktaUtil object
    that contains methods used to complete the Okta login flow.
 -->
{{{OktaUtil}}}

<script type="text/javascript">
	var config = {
    	baseUrl: orgUrl,
             idps: [
          {id: 'this_is_private', text: 'Login met Microsoft'}
        ]
    }

    // Render the Okta Sign-In Widget
    var oktaSignIn = new OktaSignIn(config);
    oktaSignIn.renderEl({ el: '#okta-login-container' },
      function success(res) {
        	if(res.status === 'SUCCESS'){
              res.session.setCookieAndRedirect(http://localhost:8080);


      },
     
      function error(err) {
        // This function is invoked with errors the widget cannot recover from:
        // Known errors: CONFIG_ERROR, UNSUPPORTED_BROWSER_ERROR
      }
    );
</script>

Hi @ymzhang23

You can configure the widget to do a simple OIDC flow and redirect you to a specific page once the flow is completed. You can find here an example for implicit flow.

From widget point of view, you will need to set a few more attributes under config:

  • redirectUri - the URL where to redirect (this needs to be whitelisted also in the OIDC app in Okta)
  • clientId: the OIDC app’s client ID which can be found under the General tab
  • authParams.issuer - the issuer of the authorization server used
  • authParams.responseType - id_token, token or both
  • authParams.display - “page”
  • authParams.scopes - the scopes requested (it can be set to openid)

Here is an example of a configuration

var oktaSignIn = new OktaSignIn({
    baseUrl: "https://org.okta.com",
    clientId: "0oall5cfosYwGzfFA0h7",
    redirectUri: "https://your.website.com/page/to/be/accessed",
    authParams: {
        issuer: "https://org.okta.com",
        responseType: ['token'],
		display: 'page',
		scopes: ['openid']
    }
});

Thank you for you reaction.

Unfortunately, you solution doesnt work. I have applied this, and still it keep me redirect to mydomain.com/app/userHome

1 Like

Hi @ymzhang23

Can you please open a support ticket with us at developers@okta.com in order to review the integration mentioned above?

Hi @dragos,

Do you mean sending an email to developers@okta.com?

Thank you again.

Hi @ymzhang23

Yes, please send us an email to developers@okta.com and one of our Developer Support Engineers will assist you.

Hello @dragos,

Thank your for your message. I just send you an email.

Hello @ymzhang23 I want to create a same , Did you app redirect the givem URL ?

Yes, but I had to fill in in the parameters. not in the config.

customButtons: [{
                title: 'Login met Microsoft',
                className: 'btn-microsoft',
                click: function() {
                  // clicking on the button navigates to another page
                  window.location.href = 'youroktadomain.com/redirect_uri=https://www.google.com&state=WM6D&nonce=YsG76jo';
                }
              }

HI @ymzhang23,
so is your location.href redirect to google.com and what state contain and noonce ,
and as per suggest by @dragos

https://${orgnaizationdomain.okta.com}/oauth2/default/v1/authorize?response_type=id_token%20token&client_id=${client_id}&redirect_uri=${mydomain/dashboard}&state=abc&scope=openid&nonce=abc

I have tried but its not work for me , I need same as facebook work in Okta , it redirect to Fb , but I want to redirect to Okta login and after success to my home page

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.