I’m calling from an SPA application the Okta API - " https://dev-286833.okta.com/api/v1/apps"; and get a Access to XMLHttpRequest at ’ https://dev-xxxxx.okta.com/api/v1/apps?user.id=xxxxx’; from origin ’ http://localhost:4200’; has been blocked by CORS policy:
- I’ve already added http://localhost:4200/ to my Security->API->Trusted Origins.
- I know the origin works because I am able to authenticate with implicit/callback and it didn’t work prior to me adding it.
- The API call from Postman works and it returns a list of apps.
Here’s my angular code:
const httpOptions = {
headers: new HttpHeaders()
.set('Accept', 'application/json')
.set('Aauthorization', 'SSWS ' + this.apiToken)
.set('Content-Type', 'application/json')
};
return this.httpClient.get(this.appsUri + '?[user.id](http://user.id/)=' + username, httpOptions);
This seems like a very straightforward API call but I can’t get it to work. Can anyone shed some light? Many thanks in advance.