Uploaded image for project: 'Keycloak'
  1. Keycloak
  2. KEYCLOAK-13100

keycloak-js 9.0.0 use the old promise type

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Duplicate Issue
    • Affects Version/s: 9.0.0
    • Fix Version/s: None
    • Component/s: Adapter - JavaScript
    • Labels:
      None
    • Docs QE Status:
      NEW
    • QE Status:
      NEW

      Description

      Migrating from keycloak-js@4.6.0 to keycloak-js@9.0.0 I got a warning in console that suggest me to use the native promise as described here https://github.com/keycloak/keycloak-documentation/blob/master/securing_apps/topics/oidc/javascript-adapter.adoc

      So i changed my code

                 refreshToken: refreshToken,
                 idToken: idToken,
                 timeSkew: timeSkew,
      -          checkLoginIframe: false
      +          checkLoginIframe: false,
      +          promiseType: 'native'
               })
      -        .success(authenticated => {
      +        .then(authenticated => {
                 if(authenticated) successFn(subject, token);
                 else errorFn();
               })
      -        .error(errorFn);
      +        .catch(errorFn);
      

      but when the login process is finished i get this error

      TypeError: kc.updateToken(...).success is not a function keycloak.js:296
          processInit keycloak.js:296
          setSuccess keycloak.js:1152
          onreadystatechange keycloak.js:854
          sentryWrapped index.js:3076
      

      the relevant line is this one https://github.com/keycloak/keycloak/blob/42773592ca61bca3953d274e6f6053f4f792361c/adapters/oidc/js/src/main/resources/keycloak.js#L296

      debugging seems that `kc.updateToken(-1)` is a native promise, so you should use .then instead of .success.

      in the console:

      kc.updateToken(-1)
      {...}
      ​
      "$$arrayListeners": Array []
      ​
      "$$catch": function catch(callback)​
      "$$finally": function finally(callback, progressBack)​
      "$$state": Object { status: 0 }
      ​
      "$$then": function then(onFulfilled, onRejected, progressBack)​
      then: function ()
      ​
      <prototype>: Object { all: callNewQ(), any: callNewQ(), bind: exports(bound), ... }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              originof Manuel Mazzuola (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: