Accessing requestContext from a custom error page

Hello,

It’s easy to access the requestContext in a custom Sign In page: just a call to OktaUtil.getRequestContext().

The documentation for custom error pages omits reference to OktaUtil, and when I try to embed it using the same syntax as described in the Sign In page documentation ({{{OktaUtil}}}) nothing is embedded in the rendered HTML.

Does anyone know if there is a way for me to access the additional context of the error in custom Javascript?

@wss_wayne Hi, I might not completely understand your question. Could you please attach your code snippets and the exact error msg?
Also, I attached a few reference here. You can take a look and try it again.
Here is definition of {{{OktaUtil}}}
And the customization samples

Hello @Lijia,

Thank you for the links. I have no problem with the Custom Sign In Page, it works as expected for me. My question relates to the Custom Error Page.

I cannot find any reference to OktaUtil in the documentation for Custom Error Page: https://developer.okta.com/docs/guides/custom-error-pages/customization-examples/

When I embed {{{OktaUtil}}} in the Custom Sign In Page, it is replaced with script, eg:

<body>
  <!-- ...etc -->

  {{{OktaUtil}}}
  <script type="text/javascript">
    var requestContext = OktaUtil.getRequestContext()
    console.log(requestContext)
  </script>
</body>

Renders as expected:

<body>
  <!-- ...etc -->
  <!-- {{{OktaUtil}}} string is replaced with -->
  <div id="okta-sign-in" class="auth-container main-container unsupported-message-container" style="display:none">
    <!-- ...etc -->
  </div>
  <script type="text/javascript">
    // ... etc
    OktaUtil.init();
  </script>
  <!-- my script... -->
</body>

And the output of my call to console is as expected

{ assets: { ... }, ... etc }

When I embed the same {{{OktaUtil}}} string and script into the Custom Error Page it renders like this:

<body>
  <!-- ...etc -->
  <!-- {{{OktaUtil}}} string disappears and is not replace with the OktaUtil code -->
  <!-- my script... -->
</body>

And my call to OktaUtil.getRequestContext() fails because OktaUtil is not defined.

So my question is: how can I access OktaUtil.getRequestContext() (or an equivalent) from my script in the Custom Error Page?

@wss_wayne Hi, can you please open a support ticket through an email to support@okta.com? We can look into the code in a remote meeting.