Hi,

I am trying to integrate Swagger UI with Keycloak OpenID (OAuth2 
compatible) as the OAuth server for my restful services running in a JBoss 
EAP 7 server.

They are role based and user based permissions.


I added this code to my Swagger index.html:


  ui.initOAuth({
        clientId: "gcid-alertas-restful-api",
        realm: "gcid",
        appName: "GCID Alertas Rest API",
        scopeSeparator: " ",
        additionalQueryStringParams: {}
      })



The resources map is:


/ for the Swagger UI


/rest/ for the WS (protected by Keycloak)


/site for the Maven site documentation



When I hit the "Authorize" button It show me the Swagger authorizations 
screen:



<about:invalid#zClosurez>


But when I fill all the data and press the button...



Fetch API cannot load 
http://-----:18080/auth/realms/gcid/protocol/openid-connect/token?client_id=gcid-alertas-restful-api&client_secret=client-secret.
 
Request header field Access-Control-Allow-Origin is not allowed by 
Access-Control-Allow-Headers in preflight response.

But the UI don't send the user name and the password nor the grand type...


If I use curl I can get the token.


C:\Users\usuario>curl -d "client_id=gcid-alertas-restful-api" -d 
"client_secret=client-secret" -d "username=usuario1" -d "password=password" 
-d "grant_type=password" 
http://-----:18080/auth/realms/gcid/protocol/openid-connect/token



So... In resume, I have a Rest API with a KC (OAuth2 server) and I want to 
link Swagger UI to the OAuth server to loggin and test the methods... It's 
working for you? I'm not sure what I doing wrong. :/

Thanks you in advance,


Nestor Almeida.


PD. CORS is enabled!

-- 
You received this message because you are subscribed to the Google Groups 
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to