# Add Authentication to Any Web Page in 10 Minutes

**URL:** <https://devforum.okta.com/t/add-authentication-to-any-web-page-in-10-minutes/16879>\
**Category:** Developer Blog Comments\
**Created:** [June 8, 2018, 2:06pm UTC](https://devforum.okta.com/t/add-authentication-to-any-web-page-in-10-minutes/16879 "2018-06-08T14:06:19Z")\
**Posts on this page:** 20\
**Page:** 4

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [August 6, 2020, 7:32pm UTC](https://devforum.okta.com/t/add-authentication-to-any-web-page-in-10-minutes/16879/61 "2020-08-06T19:32:46Z")

</div>

**Kendall LeBerte**

Oh okay, got it! Funny you should mention that - I ended up literally just copy pasting your code into my doc to try and isolate the issue (although I promise I’m not trying to just take your code by any means and appreciate the example haha!). The only things I changed are the URL and Client ID but still not having any luck after "logging in."

Is there another configuration setting or library I need to download or install somewhere you can think of? Here is the URL it is running on in case anything pops out at you : [https://everyreceiptnow.com…](https://everyreceiptnow.com/testlogin "https://everyreceiptnow.com/testlogin")

I’d also be happy to create a specific shareable test user to try logging in with if that would helpful in troubleshooting at all?

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [August 6, 2020, 8:25pm UTC](https://devforum.okta.com/t/add-authentication-to-any-web-page-in-10-minutes/16879/62 "2020-08-06T20:25:24Z")

</div>

**Matt Raible**

Thanks for testing everything, Kendall! I had a couple of typos in my Gist. Change this:

```
oktaSignIn.authClient.token.parseFromUrl(
```

To this:

```
oktaSignIn.authClient.token.parseFromUrl().then(
```

And use the `authClient` to store the ID token.

```
oktaSignIn.authClient.tokenManager.add(‘idToken’, idToken);
```

I’ve updated my Gist with these changes.

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [August 6, 2020, 8:37pm UTC](https://devforum.okta.com/t/add-authentication-to-any-web-page-in-10-minutes/16879/63 "2020-08-06T20:37:56Z")

</div>

**Kendall LeBerte**

Matt, you’re a genius! That did the trick! Thank you so much for all of your help!

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [September 10, 2020, 3:41pm UTC](https://devforum.okta.com/t/add-authentication-to-any-web-page-in-10-minutes/16879/64 "2020-09-10T15:41:07Z")

</div>

**Rakesh**

I Have tried to run this example in IE 11, But after successful authentication it is again redirecting me to the application login page. Can anyone please help me.

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [September 10, 2020, 3:49pm UTC](https://devforum.okta.com/t/add-authentication-to-any-web-page-in-10-minutes/16879/65 "2020-09-10T15:49:16Z")

</div>

**Matt Raible**

You shouldn’t have any issues with IE 11 if you’re using implicit flow. Are you using implicit flow or authorization code flow with PKCE?

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [September 10, 2020, 4:02pm UTC](https://devforum.okta.com/t/add-authentication-to-any-web-page-in-10-minutes/16879/66 "2020-09-10T16:02:48Z")

</div>

**Rakesh**

i am using authorization code flow with PKCE

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [September 10, 2020, 4:42pm UTC](https://devforum.okta.com/t/add-authentication-to-any-web-page-in-10-minutes/16879/67 "2020-09-10T16:42:39Z")

</div>

**Matt Raible**

If you want to use PKCE with IE 11, you need to polyfill the webcrypto. The list of polyfills needed is [here](https://github.com/okta/okta-auth-js#browser-compatibility--polyfill "https://github.com/okta/okta-auth-js#browser-compatibility--polyfill").

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [October 19, 2020, 4:19pm UTC](https://devforum.okta.com/t/add-authentication-to-any-web-page-in-10-minutes/16879/68 "2020-10-19T16:19:55Z")

</div>

**Sudheendra Rao**

Once i put the user name and password it still says "You are not logged in. Get outta here! Shoo! \>:S"  
Dear sir, Please help

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [October 19, 2020, 4:32pm UTC](https://devforum.okta.com/t/add-authentication-to-any-web-page-in-10-minutes/16879/69 "2020-10-19T16:32:29Z")

</div>

**Matt Raible**

If you look in your browser’s developer console, do you see any errors?

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [October 19, 2020, 4:53pm UTC](https://devforum.okta.com/t/add-authentication-to-any-web-page-in-10-minutes/16879/70 "2020-10-19T16:53:03Z")

</div>

**Sudheendra Rao**

No, I got that fixed, it was an issue with oktaSignIn.tokenManager.add(‘idToken’, idToken);  
 which i fixed by reading the complete blog. Could i ask a second stupid question. I use this on my [ASP.net](http://ASP.net "ASP.net") page C# page, it now logs in. But once logged in, how do i get the user name in to a label field i have added

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [October 19, 2020, 5:06pm UTC](https://devforum.okta.com/t/add-authentication-to-any-web-page-in-10-minutes/16879/71 "2020-10-19T17:06:05Z")

</div>

**Matt Raible**

Once you have the ID token, you should be able to read the claims from it. For example:

```
oktaSignIn.tokenManager.add(‘idToken’, idToken);document.getElementById(“messageBox”).innerHTML = "Hello, " + idToken.claims.email + “! You just logged in! :)”;
```

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [October 23, 2020, 4:50pm UTC](https://devforum.okta.com/t/add-authentication-to-any-web-page-in-10-minutes/16879/72 "2020-10-23T16:50:22Z")

</div>

**Sudheendra Rao**

Thank you sir

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [December 14, 2020, 2:29pm UTC](https://devforum.okta.com/t/add-authentication-to-any-web-page-in-10-minutes/16879/73 "2020-12-14T14:29:42Z")

</div>

**Melvin George**

[14 Dec 2020] Both 2.16.0 and 4.3.0 gives error.  
Upon entering my okta login credentials:  
2.16.0: Unable to connect to the server. Please check your network connection.  
4.3.0: There was an unexpected internal error. Please try again.  
In both the above cases, Python server shows “GET / HTTP/1.1” 200 -

The blog is written well. Adding the youtube video is good thought.  
But, the example does Not work. Could you please help me make it work.

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [December 14, 2020, 3:26pm UTC](https://devforum.okta.com/t/add-authentication-to-any-web-page-in-10-minutes/16879/74 "2020-12-14T15:26:34Z")

</div>

**Matt Raible**

I’m confident the code works. Maybe you’re running your local server on a different port? [Here’s a gist I created](https://gist.github.com/mraible/2eb7381bbd70ece490149f6161af5b57 "https://gist.github.com/mraible/2eb7381bbd70ece490149f6161af5b57") that shows the code for both versions.

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [December 15, 2020, 8:19am UTC](https://devforum.okta.com/t/add-authentication-to-any-web-page-in-10-minutes/16879/75 "2020-12-15T08:19:03Z")

</div>

**Melvin George**

Hi Matt, Thank you for the response. Yes, yesterday also I used code from the same gist link.

The System Log in Okta Dashboard reports success:  
User accessing Okta admin app - success  
OIDC access token is granted - success  
User single sign on to app - success  
OIDC id token is granted - success  
OIDC authorization code request - success  
Evaluation of sign-on policy - allow  
[First Event] User login to Okta - success

But, the browser localhost:8080 still says “There was an unexpected internal error. Please try again.” I run it via “python3 -m http.server 8080”; with 4.3.0 code in index.html

Let me know if you need some more info to fix this issue with gist code. Might help newcomers who use it as a getting started exercise.

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [December 15, 2020, 3:16pm UTC](https://devforum.okta.com/t/add-authentication-to-any-web-page-in-10-minutes/16879/76 "2020-12-15T15:16:16Z")

</div>

**Matt Raible**

I just tried using [4.3.0](https://gist.github.com/mraible/2eb7381bbd70ece490149f6161af5b57#file-10m-4-3-0-html "https://gist.github.com/mraible/2eb7381bbd70ece490149f6161af5b57#file-10m-4-3-0-html") and it works fine for me. I created an app on Okta with `http://localhost:8080` as a Login redirect URI and added `http://localhost:8080` as a trusted origin in API \> Trusted Origins.

[https://uploads.disquscdn.c…](https://uploads.disquscdn.com/images/720283458e024e98c53c7c530ca649582d0f424e23be9de84af94e0821eecece.png "https://uploads.disquscdn.com/images/720283458e024e98c53c7c530ca649582d0f424e23be9de84af94e0821eecece.png")

If this doesn’t work for you, I suspect it’s because you don’t have a “default” authorization server. If you look in API \> Authorization Servers, do you see a default one listed there? If you’re using an Okta IT Trial you won’t have this. If you’re using a developer account (like this tutorial asks you to create), everything will work.

[https://uploads.disquscdn.c…](https://uploads.disquscdn.com/images/07500664f23a8d14311cf5247c8b1345d4d139ecf3dfc067ef3d296bb4b7e5a5.png "https://uploads.disquscdn.com/images/07500664f23a8d14311cf5247c8b1345d4d139ecf3dfc067ef3d296bb4b7e5a5.png")

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [December 17, 2020, 12:02pm UTC](https://devforum.okta.com/t/add-authentication-to-any-web-page-in-10-minutes/16879/77 "2020-12-17T12:02:57Z")

</div>

**Melvin George**

Hi Matt, Thanks for the details on how you set it up. I had to do 2 things:

1) API → Trusted Origins  
Origin URL: [http://localhost:8080](http://localhost:8080)  
CORS: selected.

2) Running the server again after above change, I got another error in browser that user is not assigned/authorized or similar. To overcome this:  
Users → \<click my="" user="" id=""\>  
Assign Applications → Click “Assign” button on the application name.  
Click “Save and Go Back” → Click “Done”.

I am able to login to and see the text changed as in the tutorial.

Should i be concerned about the error I get in browser when I log out?  
It shows “400 Bad Request - Your request resulted in an error”:  
 Identity Provider:  
 Error Code: invalid\_request  
 Description: The ‘post\_logout\_redirect\_uri’ parameter must be a Logout  
 redirect URI in the client app settings:   
[https://dev-8033249-admin.o…](https://dev-8033249-admin.okta.com/admin/app/oidc_client/instance/0oa2bfa3yGJmNr7o55d6#tab-general "https://dev-8033249-admin.okta.com/admin/app/oidc\_client/instance/0oa2bfa3yGJmNr7o55d6#tab-general")

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [December 17, 2020, 1:19pm UTC](https://devforum.okta.com/t/add-authentication-to-any-web-page-in-10-minutes/16879/78 "2020-12-17T13:19:48Z")

</div>

**Matt Raible**

To fix this error, you need to update your app on Okta and add [http://localhost:8080](http://localhost:8080) as a Logout redirect URI.

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [December 23, 2020, 10:06am UTC](https://devforum.okta.com/t/add-authentication-to-any-web-page-in-10-minutes/16879/79 "2020-12-23T10:06:59Z")

</div>

**Melvin George**

Thanks, Matt. Adding [http://localhost:8080](http://localhost:8080) as a Logout redirect URI fixed the error at logout.

Wish you happy holidays!

---

<div class="post-metadata">

**Author:** ![oktadev-blog](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/oktadev-blog/32/3422_2.png) [@oktadev-blog](https://devforum.okta.com/u/oktadev-blog)\
**Post date:** [December 23, 2020, 12:36pm UTC](https://devforum.okta.com/t/add-authentication-to-any-web-page-in-10-minutes/16879/80 "2020-12-23T12:36:03Z")

</div>

**Anime.lvr21**

Ok. Thank you

[Previous page](https://devforum.okta.com/t/add-authentication-to-any-web-page-in-10-minutes/16879.md?page=3)

[Next page](https://devforum.okta.com/t/add-authentication-to-any-web-page-in-10-minutes/16879.md?page=5)
