1

I'm building an angular 5 application, using Identity Server 3 (Implicit Flow), based off this tutorial: https://www.scottbrady91.com/OpenID-Connect/Silent-Refresh-Refreshing-Access-Tokens-when-using-the-Implicit-Flow (he uses Identity 4)

so far everything is working, except for the silent refresh page's signinSilentCallback call. My page looks like:

<head>
    <title></title>
</head>
<body>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/oidc-client/1.3.0/oidc-client.js"></script>
<script>    
    new UserManager().signinSilentCallback()
        .catch((err) => {
            console.log(err);
        });
</script>
</body>

I initially was referencing the odic-client.js file directly as his sample, but either way i keep getting the below error:

VM861 silent-refresh.html:7 Uncaught ReferenceError: UserManager is not defined at VM861 silent-refresh.html:7

Not sure what i'm missing, why it can't create a reference to the UserManager object. the .js is loaded, as I see the file in Chrome's network tab. As soon as the token expires the silent-refresh.html page shows up in the network tab, along with the oidc-client.js file.

Paritosh
  • 4,243
  • 7
  • 47
  • 80

2 Answers2

1

I got it working, i had to do 2 things:

  1. In the Identity Server client, i had to set RequireConsent = false, which made sense as i'm doing a silent refresh i can't ask for constent.

  2. In the angular side, just before the call to signinSilentCallback() i had to run window.location.hash = decodeURIComponent(window.location.hash);

After that i'm seeing the token refresh.

Paritosh
  • 4,243
  • 7
  • 47
  • 80
1

This worked for me:

new Oidc.UserManager().signinSilentCallback() .catch((err) => { console.log(err); });

jamie yiw
  • 461
  • 3
  • 8