Hi,

 

I could resolve my problem. The error occurred because I used a local copy of the keycloak.js file.

Since I am using the file from the server (src =http://localhost:8180/auth/js/keycloak.js) it works fine.

 

Best regards,

Lars

 

Von: keycloak-user-bounces@lists.jboss.org [mailto:keycloak-user-bounces@lists.jboss.org] Im Auftrag von Lars Frauenrath
Gesendet: Dienstag, 28. Juli 2015 11:18
An: keycloak-user@lists.jboss.org
Betreff: [keycloak-user] JavaScript error: No Access-Control-Allow-Origin header is present...

 

Hi,

 

as the subject said I got an error while sending a request to my keycloak server.

I configured the following things:

1.       External Keycloak server (runs on localhost:8180)

a.       Add realm

b.      Add client/application

c.       Add roles

d.      Add user + roles for this user

e.      Add Url to Web Origins (http://localhost:8080)

2.       Wildfly 8 Server (runs on localhost:8080)

a.       Add keycloak adapter for wilrdfly 8

b.      Add Security domain

c.       Add subsystem for keycloak (generated from keycloak admin console)

3.       My Application

a.       Keycloak.json (generated from Keycloak admin console | “enable-cors” is set to true)

b.      Downloaded keycloak.js and added it to jsp/html pages

c.       Defined security-constraints and security-roles in web.xml

 

I got the problem while trying to login to my application. Keycloak accepts my username and password and forwards me to the first site of my application.

There I am using the keycloak.js to “login” and handle the different roles but within this workflow I got the following errors:

 

1.       “XMLHttpRequest cannot load ‘http://localhost:8180/auth/realms/TOMAMappingConfigurationService/tokens/access/codes’. No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

Origin ‘http://localhost:8080’ is therefore not allowed access. The response had HTTP status code 400. ”

2.       “XMLHttpRequest cannot load ‘http://localhost:8180/auth/realms/TOMAMappingConfigurationService/account’. No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

Origin ‘http://localhost:8080’ is therefore not allowed access. The response had HTTP status code 403. ”

 

I hope you can help me.

 

Kind regards,

Lars