Can't Implement a basic sign-in widget

Hello team :slight_smile:

I’m trying to implement Okta Widget with Glitch. I’m working with index.html file to do it.

Here the code. I’m a novice and i don’t understand why it’s not working…

<!DOCTYPE html>
<html lang="en">
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Welcome to Okta Cert</title>
	<!-- Okta Sign-In Widget: Core js and css -->
	<script src="" type="text/javascript"></script> 
	<link href="" type="text/css" rel="stylesheet"> 
  <!-- Okta Sign-In Widget: Customizable css theme options. Link your own customized copy of this file or override styles in-line -->
	<link href="" type="text/css" rel="stylesheet">
  <div class="title">Welcome to Okta Cert</div>
  <div class="title">Please enter your credentials below to continue to your Okta org.</div>

  <div id="okta-login-container"></div>

  <div class="footer">
    Copyright 2009-2022 Okta Cert. All rights reserved.

  <script type="text/javascript">
		var signIn = new OktaSignIn(
    baseUrl: 'https://{}',
    clientId: '{{0oa55nihmvUPd0qqH0x7}}',
    redirectUri: '{{}}',
    useClassicEngine: true

  // Assumes there is an empty element on the page with an id of 'osw-container'
  el: '#osw-container'
}).then(function(tokens) {
  // Store tokens
}).catch(function(error) {
  // Handle error

  <!-- Default page style -->
    .title {
      padding: 40px;
      font: normal 34px/1 Verdana, Geneva, sans-serif;
      color: black;
      text-align: center;
      letter-spacing: 7px;
    .footer {
      font: normal 14px/1 Verdana, Geneva, sans-serif;
      padding: 10px;
      color: black;
      position: fixed;
      bottom: 0;
      width: 100%;
      background-color: #F0F0F0;
  <!-- Default page style -->

Do you see something wrong in what i’ve done?

Thank you for your help :slight_smile:

Couple of things I spotted.

  1. Update your CDN sources to the latest widget version
<!-- Latest CDN production Javascript and CSS -->
<script src="" type="text/javascript"></script>

<link href="" type="text/css" rel="stylesheet"/>
  1. Remove all of the curly braces from these values
  1. Set the redirectUri above to whatever domain and route you are hosting the widget on (http://localhost:8000, etc)
  2. Update the id for your div (where the Widget will be rendered) to match the el used by showSignInToGetTokens
  1. Add code into the then for showSignInToGetTokens so that tokens are stored in TokenManager

You can check out an example config in our docs here (leave useClassicEngine: true in your config once you’re using the latest widget version): Embedded Okta Sign-In Widget fundamentals | Okta Developer

Thank you very much @andrea ,

It works fine now by matching the EL used by showSignInToGetTokens.

Thanks again :slight_smile:


1 Like

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