I would not like to rely on Keycloak login page at the moment, for that reason I have followed this example. I have configured my client as shown below:
Now this is how my request looks like:
public getToken() {
return this.http.post('http://localhost:8080/auth/realms/angular-test/protocol/openid-connect/token', {});
}
It is this method that is raising the error Access to XMLHttpRequest at 'my token endpoint url' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I am not sure what is it that I am missing here. I have tried Web Origins to *, did not work too, even the +. I am still getting the same error.
NB: I am not using any adapter, I just want to make a call to Keycloak and get the token.
EDIT: Adding request headers:
POST /auth/realms/angular-test/protocol/openid-connect/token HTTP/1.1
Host: localhost:8080
Connection: keep-alive
Content-Length: 2
Accept: application/json
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36
Content-Type: application/json
Origin: http://localhost:4200
Sec-Fetch-Site: same-site
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Referer: http://localhost:4200/
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
