<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content
0D54z00007MlLrlCAFOkta Classic EngineIntegrationsAnswered2024-01-11T03:00:42.000Z2021-12-31T18:19:20.000Z2022-01-01T19:59:49.000Z

ServiceM.47051 (Customer) asked a question.

Okta Self-hosted SignIn Widget (dotnetcore MVC) - add custom headers to all Okta API Requests

Hi!

 

We need to add a custom header to all Okta API requests that originate from the self hosted SignIn widget.

For example - the /authn request would need to have a Request Header of something like "X-My-Header" = "test".

 

Does anybody happen to have done this successfully? Any help would be greatly appreciated.

 

Thanks!


  • ServiceM.47051 (Customer)

    Looks like I was able to do this by "newing" up an instance of the authClient via:

     

    const authClient = new OktaAuth({

        issuer: orgUrl + '/oauth2/default',

        clientId: 'something',

     

        headers: {

          'X-My-Header': 'HeaderValue'

        }

      });

     

    ... and then assigning the authClient to the instance of OktaSignIn:

     

    signIn = new OktaSignIn({

        logo: siteBaseUrl + logoName,

        baseUrl: orgUrl,

        authClient: authClient,

    ...

    });

     

    This does the trick by adding the custom header for all API calls to Okta.

    The documentation found here was a bit misleading as ...

    authClient.setHeaders({

    foo: 'baz'

    });

    ... did not work. Also, the header name has to be in quotes.

    Expand Post
This question is closed.
Loading
Okta Self-hosted SignIn Widget (dotnetcore MVC) - add custom headers to all Okta API Requests