mhashim February 2016

keycloak javascript adapter request offline token

I have js application for which I use keycloak 1.7-final JavaScript adapter with public client and standard flow and it works fine but now I wanted to add offline capability to the application and don't know how to get offline token. according to the documentation the client can request offline token by adding parameter "scope=offline_access" when sending authorization request to Keycloak. The thing is I don't know where to add the parameter. I tried to add to "keycloak.config" and "keycloak.init" but its not working.

in keycloak.config:

keycloak: {
     url: 'link omitted',
     realm: 'sisdn-realm',
     clientId: 'sisdn',
     redirect_uri: 'link omitted',
     flow: 'standard',
     'enable-cors': true,
     scope: 'offline_access'
}

and in keycloak.init

const keycloakConf = require('keycloak')//this is the same config above
var keycloak = new  keycloakConf(config.keycloak)

keycloak.init({
   onLoad: 'login-required',
   checkLoginIframe: false,
   scope: 'offline_access'
})
.success(authenticated => {
   if(!authenticated)
     dispatch(loginFailure())
   else {
     global.keycloak = keycloak
     dispatch(loginSuccess())
    }
 })

Answers


Ilya February 2016

From the JS adapter code:

The init method doesn't accept the scope option, but the login method does.

Post Status

Asked in February 2016
Viewed 1,197 times
Voted 11
Answered 1 times

Search




Leave an answer