@@ -37,7 +37,9 @@ import { vueKeycloak } from '@baloise/vue-keycloak'
3737Apply the library to the vue app instance.
3838
3939``` typescript
40- createApp (App ).use (vueKeycloak , {
40+ const app = createApp (App )
41+
42+ app .use (vueKeycloak , {
4143 initOptions: {
4244 flow: ' standard' , // default
4345 checkLoginIframe: false , // default
@@ -48,15 +50,21 @@ createApp(App).use(vueKeycloak, {
4850 realm: ' myrealm' ,
4951 clientId: ' myapp'
5052 }
51- }).mount (' #app' )
53+ })
54+ ```
55+
56+ Or use a JSON file with the configs.
57+
58+ ``` typescript
59+ app .use (vueKeycloak , ' /keycloak.json' )
5260```
5361
5462### Configuration
5563
56- | Config | Type | Description |
57- | ----------- | ----------------------------------- | ---------------------------------------- |
58- | initOptions | ` Keycloak.KeycloakInitOptions ` | ` initOptions ` is Keycloak init options. |
59- | config | ` string \| Keycloak.KeycloakConfig` | ` config ` are the Keycloak configuration. |
64+ | Config | Type | Description |
65+ | ----------- | ------------------------------ | ---------------------------------------- |
66+ | initOptions | ` Keycloak.KeycloakInitOptions ` | ` initOptions ` is Keycloak init options. |
67+ | config | ` Keycloak.KeycloakConfig ` | ` config ` are the Keycloak configuration. |
6068
6169Use the example below to generate dynamic Keycloak conifiguration.
6270
@@ -76,29 +84,15 @@ app.use(vueKeycloak, async () => {
7684})
7785```
7886
79- Or load the Keycloak configuration from a json file.
80-
81- ``` typescript
82- app .use (vueKeycloak , async () => {
83- return {
84- config: ' http://localhost:8080/myapp/keycloak.json' ,
85- }
86- })
87- ```
88-
8987> It is also possible to access the keycloak instance with ` getKeycloak() `
9088
9189## Use Token
9290
9391We export two helper functions for the token.
9492
95- ### isTokenReady
96-
97- This functions returs a promise and only gets resolved if we have received a token.
98-
9993### getToken
10094
101- This promise returns a token. ` isTokenReady ` gets called inside this function .
95+ This function checks if the token is still valid and will update it if it is expired .
10296
10397> Have a look at our [ vueAxios] ( https://github.com/baloise/vue-axios ) plugin.
10498
@@ -157,21 +151,23 @@ const {
157151 decodedToken,
158152 username,
159153 roles,
154+ keycloak,
160155
161156 // Functions
162157 hasRoles,
163158} = useKeycloak ()
164159```
165160
166- | State | Type | Description |
167- | --------------- | --------------- | ------------------------------------------------------ |
168- | isAuthenticated | ` Ref<boolean> ` | If ` true ` the user is authenticated. |
169- | isPending | ` Ref<boolean> ` | If ` true ` the authentication request is still pending. |
170- | hasFailed | ` Ref<boolean> ` | If ` true ` authentication request has failed. |
171- | token | ` Ref<string> ` | ` token ` is the raw value of the JWT token. |
172- | decodedToken | ` Ref<T> ` | ` decodedToken ` is the decoded value of the JWT token. |
173- | username | ` Ref<string> ` | ` username ` the name of our user. |
174- | roles | ` Ref<string[]> ` | ` roles ` is a list of the users roles. |
161+ | State | Type | Description |
162+ | --------------- | --------------------------- | ------------------------------------------------------ |
163+ | isAuthenticated | ` Ref<boolean> ` | If ` true ` the user is authenticated. |
164+ | isPending | ` Ref<boolean> ` | If ` true ` the authentication request is still pending. |
165+ | hasFailed | ` Ref<boolean> ` | If ` true ` authentication request has failed. |
166+ | token | ` Ref<string> ` | ` token ` is the raw value of the JWT token. |
167+ | decodedToken | ` Ref<T> ` | ` decodedToken ` is the decoded value of the JWT token. |
168+ | username | ` Ref<string> ` | ` username ` the name of our user. |
169+ | roles | ` Ref<string[]> ` | ` roles ` is a list of the users roles. |
170+ | keycloak | ` Keycloak.KeycloakInstance ` | ` keycloak ` is the instance of the keycloak-js adapter. |
175171
176172#### Functions
177173
0 commit comments