Unable to get id_token by using parseFromUrl

I’m trying to get id_token from the url (as suggested here) and when I use the following implementation there is no idToken (undefined).

 if (!this.signIn.hasTokensInUrl()) {
    this.signIn.renderEl({el: '#sign-in-widget'},
      function() {},
      function(err) { console.error(err) });
  } else {
    console.log('signIn', this.signIn);
    const idToken = this.signIn.authClient.tokenManager.get('idToken')
    .then(idToken => {
      // If ID Token exists, output it to the console
      if (idToken) {
        console.log(`hi ${idToken}!`);
      // If ID Token isn't found, try to parse it from the current URL
      } else if (location.hash) {
        .then(idToken => {
          console.log(`hi ${idToken}!`);
          // Store parsed token in Token Manager
          this.signIn.authClient.tokenManager.add('idToken', idToken);
      } else {
        // You're not logged in, you need a sessionToken
          responseType: 'id_token'

Previously I got this working from the following implementation but my application was redirecting twice and I’m trying to change it to the above implementation.

this.signIn = new OktaSignIn({
            { el: '#sign-in-widget' },
            () => { },
             * In this flow, the success handler will not be called because we redirect
             * to the Okta org for the authentication workflow.
             * I'm not sure how to get a success response but my application works

            err => {
              throw err;

          if (this.signIn.hasTokensInUrl()) {
            this.processingToken = true;

    public async processTokens() {
        await this.oktaService.handleAuthentication(); // here I'm parsing tokens from url
        await this.setUserInfoWithOktaToken(); // here I'm setting userInfo
        await this.router.navigateByUrl(this.redirectUrl); // url = /main

I’m using

okta-signin-widget (3.1.5)
okta-angular (1.1.0)
angular (6)

This is my first time asking a question here, please let me know if I need to provide any more details