I have an angular app that is authenticating with okta, and then passing a bearer token to a Web API 2.0 C# service. I am consistently getting a 401 when I try to authorize requests.
The angular app returns an authtoken succesfully
this.oktaAuth.getAccessToken().then(accessToken => {
…
}
which is being passed in the header (which I have verified)
const headers = new HttpHeaders(
{ Authorization: ‘Bearer "’ + this.accessToken + ‘"’ }
to a Web API 2.0 server, which is configuration in the Startup.cs file to authorize the requests:
public void Configuration(IAppBuilder app)
{
string oktaDomain = ConfigurationManager.AppSettings[“okta:OktaDomain”];
string clientId = ConfigurationManager.AppSettings[“okta:ClientId”];
app.UseOktaWebApi(new OktaWebApiOptions()
{
OktaDomain = oktaDomain,
ClientId = clientId
});
}
the OktaDomain I have set to both the domain e.g. https://dev-xxxxx.oktapreview.com, and the domain plus the application server end point e.g. https://dev-xxxxx.oktapreview/oauth2/default
I originally passed the token without the double quotes, but the API would just hang.
any ideas?