d4rkstar / kong-konga-keycloak

short tutorial to install kong, keycloak and konga in docker and test API authentication
278 stars 129 forks source link

Invalid Token #5

Closed mohitt13 closed 2 years ago

mohitt13 commented 3 years ago

I am getting an invalid token response from the server when i try to hit the the endpoint via the proxy i have created on kong. The curl command i am using to hit the proxy -

curl --location --request GET 'http://localhost:8000/listProducts/' \ --header 'Accept: application/json' \ --header 'Authorization: Bearer token'

to get the token i use the following curl - curl --location --request POST 'http://localhost:8180/auth/realms/experimental/protocol/openid-connect/token' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'username=username' \ --data-urlencode 'password=password' \ --data-urlencode 'grant_type=password' \ --data-urlencode 'client_id=myapp'

The config i have done in the Oidc plugin:

consumer:

response type: code: introspection endpoint: http://192.168.1.207:8180/auth/realms/experimental/protocol/openid-connect/token/introspect filters: bearer only: yes ssl verify: no session secret: introspection endpoint auth method: realm: experimental redirect after logout uri: / scope: openid token endpoint auth method: client_secret_post: logout path: /logout client id: kong discovery: https://192.168.1.207:8180/auth/realms/master/.well-known/openid-configuration client secret: myClientSecret recovery page path: redirect uri path:

Thanks in advance

alihossein commented 3 years ago

I have the same problem

alihossein commented 3 years ago

@mohitt13 if find any solution please share it with us.

bhushan-chaudhari commented 3 years ago

I am getting an invalid token response from the server when I try to hit the the endpoint via the proxy i have created on kong. The curl command i am using to hit the proxy -

curl --location --request GET 'http://localhost:8000/listProducts/' --header 'Accept: application/json' --header 'Authorization: Bearer token'

to get the token i use the following curl - curl --location --request POST 'http://localhost:8180/auth/realms/experimental/protocol/openid-connect/token' --header 'Content-Type: application/x-www-form-urlencoded' --data-urlencode 'username=username' --data-urlencode 'password=password' --data-urlencode 'grant_type=password' --data-urlencode 'client_id=myapp'

The config i have done in the Oidc plugin:

consumer:

response type: code: introspection endpoint: http://192.168.1.207:8180/auth/realms/experimental/protocol/openid-connect/token/introspect filters: bearer only: yes ssl verify: no session secret: introspection endpoint auth method: realm: experimental redirect after logout uri: / scope: openid token endpoint auth method: client_secret_post: logout path: /logout client id: kong discovery: https://192.168.1.207:8180/auth/realms/master/.well-known/openid-configuration client secret: myClientSecret recovery page path: redirect uri path:

Thanks in advance

By looking at your config you generating token from localhost and passing it to 192.168.1.207 to validate.

I will recommend using below link to generate token and check

http://192.168.1.207:8180/auth/realms/experimental/protocol/openid-connect/token to generate a token

mohitt13 commented 3 years ago

@bhushan-chaudhari Thank you for the suggestion, I resolved the issue by doing what you have suggested and some minute changes in the request. @bhushan-chaudhari I used my Host IP instead of localhost and modified the headers that I was passing in my request and also used the request transformer plugin available in the kong plugins list, I suggest you to check if you are passing all the necessary headers in your request.

d4rkstar commented 3 years ago

@mohitt13 do you think this issue can be marked as closed?

d4rkstar commented 2 years ago

Closing this because no update in some months