thomabig
03/27/2024, 11:33 PMPKCE verification failed.
Here is the code I use and how I've configured the project :
import { useEffect } from 'react';
import './App.css';
import { MedplumClient } from '@medplum/core';
const medplum = new MedplumClient({
clientId: 'b7072885-b0d8-44d6-98e7-2179a66f8c65', //Found in the ClientApplication in the Medplum server
baseUrl: 'http://localhost:8103/', //Medplum server URL
});
function App() {
useEffect(() => {
const code = new URLSearchParams(window.location.search).get('code');
if (code) {
// Process the code
// On success, remove the query string parameters
medplum
.processCode(code)
.then(() => (window.location.href = window.location.href.split('?')[0]))
.catch(console.error);
}
})
let handleLogin = () => {
medplum.signInWithExternalAuth(
"http://localhost:8080/realms/medplumtest/protocol/openid-connect/auth",//Found in the Keycloak medplumtest realm settings
"medplumtest", // Found in the Keycloak realm list
"http://localhost:8103/auth/external", //Redirection to the Medplum server
{
projectId: "c23721b0-00f8-4e55-8154-8478d12b65c8", //Found in Admin > Project > Details > Id
clientId: "b7072885-b0d8-44d6-98e7-2179a66f8c65", //Found in the ClientApplication in the Medplum server
redirectUri: "http://localhost:5173/",
})
}
return (
<>
<button onClick={handleLogin}>Login</button>
</>
)
}
export default App
If anyone can help that would be great ! @rahul1thomabig
04/02/2024, 10:27 PMrahul1
04/03/2024, 12:50 AMthomabig
04/04/2024, 10:43 PM2024-04-05 00:40:22 2024-04-04 22:40:22,761 WARN [org.keycloak.protocol.oidc.utils.PkceUtils] (executor-thread-58) PKCE code verifier not specified, authUserId = aec2fa5a-a724-4c20-a7e8-19b6f5f6cbaf, authUsername = thomabigueres
2024-04-05 00:40:22 2024-04-04 22:40:22,762 WARN [org.keycloak.events] (executor-thread-58) type="CODE_TO_TOKEN_ERROR", realmId="8b7bcba1-8540-45f6-a43d-fb7193079034", clientId="medplumtest", userId="aec2fa5a-a724-4c20-a7e8-19b6f5f6cbaf", ipAddress="192.168.65.1", error="code_verifier_missing", grant_type="authorization_code", code_id="c2a51dd9-2763-4cbe-9771-02b310055bef", client_auth_method="client-secret"thomabig
04/04/2024, 10:49 PMthomabig
04/04/2024, 11:57 PMthomabig
04/04/2024, 11:58 PMrahul1
04/08/2024, 7:47 AMrahul1
04/08/2024, 7:49 AMrahul1
04/08/2024, 7:50 AMpkceEnabled to false in your call to signInWithExternalAuth?thomabig
04/09/2024, 9:16 PMrahul1
04/15/2024, 4:32 AMthomabig
04/15/2024, 12:42 PM