Hi There,
I’m pulling my hair out trying to get any of the quickstart guides to work. All I want is a website which is effectively gated by the Okta Sign-in widget. If you are not signed in to Okta you can’t access website, if you sign in using an Okta account you can access the website.
It’ll be a PHP website so the obvious choice is this guide:
However nothing really works! The first hurdle I come across is this error setting up the Sign-in widget using the example front end code:
Uncaught TypeError: Cannot read property 'hasTokensInUrl' of undefined
caused by the line:
if (oktaSignIn.token.hasTokensInUrl()) {
Doing some googling I found this post which gives some alternative code for the oktaSignIn object:
This stops a lot of the errors and it appears I get logged in and the id_token, state, bearer etc get passed back in the url starting with ‘#id_token=’ after my url.
That brings up another error:
token.js:654 Uncaught TypeError: e.indexOf is not a function
at b (token.js:654)
at Object.parseFromUrl (util.js:70)
at (index):92
b @ token.js:654
(anonymous) @ util.js:70
(anonymous) @ (index):92
If I comment out the code about tokens, then the rest of the code works within the section:
oktaSignIn.authClient.session.get().then(function (res) {...
So I get a console log of ‘Welcome back, xxxx’
It seems other people also have this issue:
So the big question is - is there actually an example or start up guide for the sign-in widget that actually works?? Can I confirm that it’s not me, and that I’m not going crazy but the official docs and getting started guides are broken?!?
Cheers,
Tom