baptisteArno / typebot.io

💬 Typebot is a powerful chatbot builder that you can self-host.
https://typebot.io
Other
7.02k stars 1.91k forks source link

error with use keycloak #1705

Open amirmdehghanpour opened 1 month ago

amirmdehghanpour commented 1 month ago

hi i conf my keycloak server same as doc but i get error Try signing with a different account. and when i check log of docker get this [next-auth][error][SIGNIN_OAUTH_ERROR] https://next-auth.js.org/errors#signin_oauth_error Unable to find matching target resource method (For more on this error consult the server log at the debug level.) { error: { message: 'Unable to find matching target resource method (For more on this error consult the server log at the debug level.)', stack: 'OPError: Unable to find matching target resource method (For more on this error consult the server log at the debug level.)\n' + ' at processResponse (/app/node_modules/.pnpm/openid-client@5.6.5/node_modules/openid-client/lib/helpers/process_response.js:38:13)\n' + ' at Issuer.discover (/app/node_modules/.pnpm/openid-client@5.6.5/node_modules/openid-client/lib/issuer.js:151:18)\n' + ' at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n' + ' at async openidClient (/app/node_modules/.pnpm/next-auth@4.22.1_next@14.1.0_@babel+core@7.24.0_react-dom@18.2.0_react@18.2.0__react@18.2.0___am5p4555usmjvg5xfootnx4hbe/node_modules/next-auth/core/lib/oauth/client.js:16:14)\n' + ' at async getAuthorizationUrl (/app/node_modules/.pnpm/next-auth@4.22.1_next@14.1.0_@babel+core@7.24.0_react-dom@18.2.0_react@18.2.0__react@18.2.0___am5p4555usmjvg5xfootnx4hbe/node_modules/next-auth/core/lib/oauth/authorization-url.js:70:18)\n' + ' at async Object.signin (/app/node_modules/.pnpm/next-auth@4.22.1_next@14.1.0_@babel+core@7.24.0_react-dom@18.2.0_react@18.2.0__react@18.2.0___am5p4555usmjvg5xfootnx4hbe/node_modules/next-auth/core/routes/signin.js:38:24)\n' + ' at async AuthHandler (/app/node_modules/.pnpm/next-auth@4.22.1_next@14.1.0_@babel+core@7.24.0_react-dom@18.2.0_react@18.2.0__react@18.2.0___am5p4555usmjvg5xfootnx4hbe/node_modules/next-auth/core/index.js:260:26)\n' + ' at async NextAuthApiHandler (/app/node_modules/.pnpm/next-auth@4.22.1_next@14.1.0_@babel+core@7.24.0_react-dom@18.2.0_react@18.2.0__react@18.2.0___am5p4555usmjvg5xfootnx4hbe/node_modules/next-auth/next/index.js:22:19)\n' + ' at async z (/app/apps/builder/.next/server/chunks/5043.js:1:8413)\n' + ' at async K (/app/node_modules/.pnpm/next@14.1.0_@babel+core@7.24.0_react-dom@18.2.0_react@18.2.0__react@18.2.0/node_modules/next/dist/compiled/next-server/pages-api.runtime.prod.js:20:16545)', name: 'OPError' }, providerId: 'keycloak', message: 'Unable to find matching target resource method (For more on this error consult the server log at the debug level.)' } and this is Screenshot of the error when i click to login with keycloak i get Screenshot 2024-08-15 at 09-03-08 Sign In Typebot

baptisteArno commented 1 month ago

Can you share your config?

amirmdehghanpour commented 1 month ago

yes this is my .env file

` ENCRYPTION_SECRET=xxxxxxxxxxxxx

DATABASE_URL=postgresql://postgres:typebot@typebot-db:5432/typebot

NODE_OPTIONS=--no-node-snapshot

NEXTAUTH_URL=https://app.setadeiran.com NEXT_PUBLIC_VIEWER_URL=https://bot.setadeiran.com

ADMIN_EMAIL=amirm.dehghanpour@gmail.com

For more configuration options check out: https://docs.typebot.io/self-hosting/configuration

SMTP_USERNAME=xxxxxxxxxxxxxxxx SMTP_PASSWORD=xxxxxxxxxxxx SMTP_HOST=mail.setadeiran.com SMTP_PORT=465 NEXT_PUBLIC_SMTP_FROM="'Typebot Notifications' info@setadeiran.com"

KEYCLOAK_CLIENT_ID=typebot KEYCLOAK_CLIENT_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxx KEYCLOAK_REALM=master KEYCLOAK_BASE_URL=https://key.amirmdehghanpour.ir/ and this is my keycloak conf { "realm": "master", "auth-server-url": "https://key.amirmdehghanpour.ir/", "ssl-required": "external", "resource": "typebot", "credentials": { "secret": "xxxxxxxxxxxxxxxxxx " }, "confidential-port": 0 }` Screenshot 2024-08-16 at 12-17-13 Keycloak Administration Console Screenshot 2024-08-16 at 12-17-05 Keycloak Administration Console

baptisteArno commented 1 month ago

Have you tried KEYCLOAK_BASE_URL=https://key.amirmdehghanpour.ir/ without end slash?

amirmdehghanpour commented 1 month ago

yes i tried but no change effect its get same error

baptisteArno commented 4 weeks ago

I am not familiar with Keycloak so I am running out of idea 🤔

baptisteArno commented 4 weeks ago

The error is OPError: Unable to find matching target resource method (For more on this error consult the server log at the debug level.)

amirmdehghanpour commented 4 weeks ago

how fix it?

amirmdehghanpour commented 4 weeks ago

i check the typebot log in docker and get this again!!! Screenshot from 2024-08-20 19-39-23

brmattge commented 1 week ago

Hi, @amirmdehghanpour, I checked, and your error seems similar to one I encountered.

I was able to authenticate successfully via Keycloak with the following settings:

image

In the Keycloak admin interface, I configured it as follows:

image

image

Let me know if this works for you too!

amirmdehghanpour commented 1 week ago

Hi, @amirmdehghanpour, I checked, and your error seems similar to one I encountered.

I was able to authenticate successfully via Keycloak with the following settings:

image

* Make sure to use double quotes for KEYCLOAK_CLIENT_ID and KEYCLOAK_CLIENT_SECRET.

* The KEYCLOAK_BASE_URL needs to include /auth/realms in your Keycloak domain. For example: https://yourdomainkeycloak/auth/realms

In the Keycloak admin interface, I configured it as follows:

image

image

Let me know if this works for you too!

hi @brmattge i change env like you say but didint work