OktaSignIn doesn't work perfectly Skip to main content
https://support.okta.com/help/answers?id=9062a000000xzs4qag&refurl=http%3a%2f%2fsupport.okta.com%2fhelp%2fanswers
How satisfied are you with the Okta Help Center?
Thank you for your feedback!
How satisfied are you with the Okta Help Center?
1
2
3
4
5
Very Dissatisfied
Very satisfied
Enter content less than 200 characters.
Ask Search:
Liang SunLiang Sun 

OktaSignIn doesn't work perfectly

I have encountered a problem when I tried OktaSignIn for authentication and the basic code is shown below. When I access login.php, the auth page is shown up to ask valid user/password. If I don't input anything but just refresh this page, OktaSignIn automatically rendered to success(res) function which by passed the real authenticating and is a big hole. I am not sure if I used it in a wrong way, or a preblem of the OktaSignIn. anyone can help on it? Thanks 

login.php
<!DOCTYPE html>
<link type="text/css" rel="stylesheet" href="https://ok1static.oktacdn.com/assets/js/sdk/okta-signin-widget/1.11.0/css/okta-theme.css" />
<link type="text/css" rel="stylesheet" href="https://ok1static.oktacdn.com/assets/js/sdk/okta-signin-widget/1.11.0/css/okta-sign-in.min.css" />
<script type="text/javascript" src="https://ok1static.oktacdn.com/assets/js/sdk/okta-signin-widget/1.11.0/js/okta-sign-in.min.js"></script>

<div id="okta-login"></div>
<script>
    var signIn = new OktaSignIn(/*config*/);
    signIn.renderEl(
        {el: '#okta-login'},
        function success(res) {
            if (res.status === 'SUCCESS') {
               window.location.reload();
            }
        }
    );
</script>
Joshua KroezeJoshua Kroeze (Okta)
Hi Liang Sun,

Thanks for your post on the community. I am trying to understand what you are writing here. Since the widget is using javascript, all code is rendered on the client (including the success flow). Once the user is succesfully authenticated - and only then - a cookie will be set for the established Okta session. There are also flows for checking if the user already has a session etc.

More information is available here: https://developer.okta.com/code/javascript/okta_sign-in_widget_ref