W
Wasp•7d ago
Phuong

I am trying to use helpers keycloak

I did all thing in https://wasp-lang.dev/docs/auth/social-auth/keycloak, I run created server keycloak, add the KeyCloakbutton,... but when I click on the button, it failed Did I miss something? I run code in WSL
No description
No description
No description
No description
No description
6 Replies
kapa.ai
kapa.ai•7d ago
Hi @Phuong. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the information provided in the knowledge sources, there are a few things to consider regarding your Keycloak integration with Wasp and the issue you're experiencing: 1. Keycloak Setup: Ensure you've followed all the steps in the Keycloak Auth setup guide (https://wasp-lang.dev/docs/auth/social-auth/keycloak#setting-up-keycloak-auth), including adding the necessary environment variables. 2. WSL Considerations: Since you're running the code in WSL, there might be some file system-related issues. Wasp has known issues with hot reloading when running on the Windows file system through WSL. Make sure your project is located on the Linux file system within WSL, not on the Windows file system. You can refer to this guide for Wasp development on WSL (https://wasp-lang.dev/blog/2023/11/21/guide-windows-development-wasp-wsl) for more details. 3. Environment Variables: Double-check that you've correctly set up the environment variables in your .env.server file:
KEYCLOAK_CLIENT_ID=your-keycloak-client-id
KEYCLOAK_CLIENT_SECRET=your-keycloak-client-secret
KEYCLOAK_REALM_URL=<https://your-keycloak-url.com/realms/master>

KEYCLOAK_CLIENT_ID=your-keycloak-client-id
KEYCLOAK_CLIENT_SECRET=your-keycloak-client-secret
KEYCLOAK_REALM_URL=<https://your-keycloak-url.com/realms/master>

4. WASP_SERVER_URL: Make sure you've defined the WASP_SERVER_URL server environment variable, especially if you're running this in a deployed environment. For local development, it defaults to <http://localhost:3001.> 5. Redirect URLs: Verify that you've updated the redirect URLs in your Keycloak client settings to match the new format: {serverUrl}/auth/{provider}/callback If you've double-checked all these points and are still experiencing issues, it would be helpful to have more specific information about the error you're encountering when clicking the button. The knowledge sources don't provide enough information to troubleshoot further without more details about the specific error or behavior you're seeing. Keycloak Auth Documentation (https://wasp-lang.dev/docs/auth/social-auth/keycloak) ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Phuong, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
Phuong
PhuongOP•7d ago
I got to login page keycloak, but after I login, it failed
No description
Filip
Filip•7d ago
Hey @Phuong, you set your KEYCLOAK_REALM_URL to your-keycloak-url.com, which is a placeholder link 😄
Phuong
PhuongOP•7d ago
I fixed but it show above page @Filip
MEE6
MEE6•7d ago
Wohooo @Phuong, you just became a Waspeteer level 2!
miho
miho•3d ago
It redirects to HTTPS://localhost:3000 but you don't have HTTPS locally. I'm not sure if this is how Keycloak usually works or you configured the redirect URL to include HTTPS? I used npx localtunnel --port 3001 to get a HTTPS link that works locally (And then I had to set WASP_SERVER_URL and REACT_APP_API_URL to it)

Did you find this page helpful?