
ServiceM.47051 (Customer) asked a question.
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!

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.