You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: _source/_posts/2025-02-07-okta-hosted-sign-in-widget.md
+24-8
Original file line number
Diff line number
Diff line change
@@ -53,6 +53,7 @@ We're not here to change the button color or simply slap a logo on the widget; w
53
53
We will accomplish this by utilizing standard Javascript and CSS.
54
54
If you use the Okta-hosted widget, you will find it under **Customizations** > **Brands** > **[your custom brand]** > **Pages** > **Sign-in** page. Click the **Configure** button and toggle the **Code editor** to **ON**. At this point, you should see some code appear like the one below:
55
55
56
+
{% raw %}
56
57
```html
57
58
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
58
59
<html>
@@ -104,6 +105,7 @@ If you use the Okta-hosted widget, you will find it under **Customizations** > *
104
105
</body>
105
106
</html>
106
107
```
108
+
{% endraw %}
107
109
108
110
Let's make a note of a few key things:
109
111
-`OktaUtil` is a global object that contains all of the widget methods and settings
@@ -115,6 +117,7 @@ If you want more fine-grained control over the widget's appearance, Okta allows
115
117
116
118
Within the `<head>` section and below the following code,
## Enhancing the experience with Okta Custom Sign-In Widget
549
559
Now, let's get into the meat and potatoes. We first need to hide some unwanted pieces of the widget (logo, header, links, etc.). Then, we must apply CSS to the existing HTML objects by replacing the classes (e.g., making the social button round). Easier said than done!
@@ -555,16 +565,20 @@ To manipulate the pieces of the widget, we need to know what those HTML elements
555
565
Additionally, I've included some extra code to showcase how you can style or manipulate the widget based on the client id, making per application customizations possible.
556
566
557
567
Below the OktaUtil object,
568
+
569
+
{% raw %}
558
570
```html
559
571
<!--
560
572
"OktaUtil" defines a global OktaUtil object
561
573
that contains methods used to complete the Okta login flow.
562
574
-->
563
575
{{{OktaUtil}}}
564
576
```
577
+
{% endraw %}
565
578
566
-
Add the following code:
579
+
Add the following code:
567
580
581
+
{% raw %}
568
582
```html
569
583
<!-- Let's add a reference to jQuery for easy object manipulation. You do not have to do this, you can use vanila JS instead -->
570
584
@@ -575,14 +589,14 @@ Add the following code:
575
589
PLEASE SEE THE FOLLOWING LINK: https://developer.okta.com/docs/guides/custom-widget-gen3/main/
576
590
*****/
577
591
578
-
// if you are interested in seeing what all is in the setttings object log it here and use your browser's dev tools to look at it
592
+
// if you are interested in seeing what all is in the settings object, log it here and use your browser's dev tools to look at it
579
593
console.log("OKTAUTIL object: ", OktaUtil);
580
594
581
-
// get request context - this allows us to get access to any data that was passed in the /authorize request...see BONUS CODE section later for a sample code
595
+
// get request context - this allows us to get access to any data that was passed in the /authorize request...see the BONUS CODE section later for a sample code
// "config" object contains the default widget configuration
586
600
// with any custom overrides defined in your admin settings.
587
601
var config =OktaUtil.getSignInWidgetConfig();
588
602
console.log("CONFIG object: ", config);
@@ -626,7 +640,7 @@ Add the following code:
626
640
{type:'Microsoft', id:'[ID OF YOUR MICROSOFT IDP FROM OKTA]'}
627
641
];
628
642
629
-
// display the social buttons first, before the username/password form
643
+
// display the social buttons before the username/password form
630
644
config.idpDisplay="PRIMARY";
631
645
632
646
// enable registration
@@ -640,13 +654,13 @@ Add the following code:
640
654
OktaUtil.completeLogin,
641
655
function(error) {
642
656
// Logs errors that occur when configuring the widget.
643
-
// Remove or replace this with your own custom error handler if desired.
657
+
// Remove or replace this with your custom error handler if desired.
644
658
console.log(error.message, error);
645
659
}
646
660
);
647
661
648
662
// Initialize another Okta widget object and Bootstrap into the Signup part...
649
-
//this is needed so we can flip between login and registration as only one instance can be rendered at a time.
663
+
//This is needed to flip between login and registration, as only one instance can be rendered at a time.
650
664
var oktaSignUp =newOktaSignIn({
651
665
issuer:config.baseUrl,
652
666
flow:'signup'
@@ -726,6 +740,8 @@ Add the following code:
726
740
};
727
741
</script>
728
742
```
743
+
{% endraw %}
744
+
729
745
Feel free to preview your work by clicking the **Save to draft** button and then the **Preview** button at the top, but just know there is one last step before we can see the final result.
730
746
731
747
## Content Security Policy to allow trusted external resources
@@ -755,6 +771,6 @@ For more examples of customizing the Okta Sign-In Widget check out these blogs a
755
771
-[A Secure and Themed Sign-in Page](blog/2023/01/12/signin-custom-domain#set-up-the-angular-micro-frontend-site-and-add-okta)
756
772
-[i18n in Java 11, Spring Boot, and JavaScript](blog/2019/02/25/java-i18n-internationalization-localization)
757
773
-[Style the Sign-In page](https://developer.okta.com/docs/guides/custom-widget/main/#modify-the-css)
And to learn more content on ways you can customize your app's login experience, follow us @OktaDev on [X](https://twitter.com/oktadev) and subscribe to our [YouTube channel](https://www.youtube.com/c/OktaDev/)! We also want to hear from you about topics you want to see and questions you may have so please leave us a comment below!
0 commit comments