forked from chaimeleon-eu/dataset-explorer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppKeycloak.tsx
47 lines (41 loc) · 1.54 KB
/
AppKeycloak.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { ReactKeycloakProvider } from "@react-keycloak/web";
import type {
AuthClientEvent,
AuthClientError
} from '@react-keycloak/core'
import keycloakConfig from './keycloak';
import React, { useState, useCallback } from "react";
import config from "./service/config";
import App from "./App";
function AppKeycloak() {
const [keycloakReady, setKeycloakReady] = useState(false);
// const [keycloakProviderInitConfig, setKeycloakProviderInitConfig] = useState(
// {"redirectUri": window.location.href});
const onEvent = useCallback((event?: AuthClientEvent | null, error?: AuthClientError | undefined ) => {
//console.log('onKeycloakEvent', event);
if (event && (event === 'onReady')) {
setKeycloakReady(true);
}
if (error) {
console.error(error);
setKeycloakReady(true);
//postMessage(new Message(Message.ERROR, "Keycloak provider error", error.error))
}
//console.log('keycloak ready', keycloakReady);
}, []);
const tokenLogger = (tokens?: any) => {
console.log('onKeycloakTokens');//, tokens)
}
return (
<ReactKeycloakProvider authClient={keycloakConfig}
initOptions={config.keycloak.initOptions}
onEvent={onEvent}
onTokens={tokenLogger}
// initOptions={{
// adapter: "default",
// }}
// LoadingComponent={<Loading />}
><App keycloakReady={keycloakReady}/></ReactKeycloakProvider>
);
}
export default AppKeycloak;