Exercise 2: Authentication in Vue.js fronted application
Previous(Optional) Exercise 1: Setup the web-application and Microservices locallyNextExercise 3: Authorization in Quarkus application
Last updated
Last updated
There are several ways to use Keycloak from web applications. The easiest option is to use the official Keycloak JavaScript client library which is defined as dependency in package.json.
The shows the simplified architecture:
The Vue.js application triggers the authentication directly when the application is opened. See the file main.js:
In order to use the Keycloak API, three pieces of information are required. The Keycloak URL
, the realm
and the client id
.
As you see in the image below the Vuex store
saves access token
, id token
and user name
. When the tokens expire, new tokens are requested via the refresh token und the Vuex store is updated.