title: How to refresh the IdToken using refreshToken Value in AWS Cognito?
body: <p>Is it possible we can force expire before one hour and get new IdToken using the refresh token
  OR
  How to get new IdToken after auto expire time using refreshToken value in this  <a href="https://www.npmjs.com/package/amazon-cognito-identity-js-node" rel="nofollow noreferrer">amazon-cognito-identity-js-node</a> module?</p>
  
  <p>I am getting</p>
  
  <blockquote>
    <p>TypeError: refreshToken.getToken is not a function as error.</p>
  </blockquote>
  
  <p>I am using this code as follows:</p>
  
  <pre><code>cognitoUser.refreshSession(refreshToken, (err, session) =&gt; {
                            if (err) {//throw err;
                              console.log('In the err'+err);
                            }
                            else{
                              console.log('session '+session);
                            }
                      }); 
  </code></pre>
  
  <p>I am passing <code>refreshToken</code> correct value in the function. 
  In the file CognitoUser.js on function </p>
  
  <pre><code>refreshSession(refreshToken, callback)
  {
    const authParameters = {};
    authParameters.REFRESH_TOKEN = refreshToken.getToken(); /* Here I am getting error*/
    ...
    ....
  }
  </code></pre>
  
  <p>In case if I replace second line of function <code>refreshSession()</code> with the </p>
  
  <pre><code>authParameters.REFRESH_TOKEN = this.signInUserSession.getRefreshToken().getToken();
  </code></pre>
  
  <p>then error went off.</p>
  
  <p>I have tried to use the code as follows:</p>
  
  <pre><code> var poolData = {
          UserPoolId: 'xx-xxx-x_xxxxx',
          ClientId: 'xxxxx',
          AuthFlow: 'xxxxx'
       };
  
       userPool = new AWS.CognitoIdentityServiceProvider.CognitoUserPool(poolData);
  
  
  if(minuteDiff &gt;= 60) { // Defult Id Token Expired
      // Get New IdToken using RefreshToken
      var userData = {
          Username : cognitousername,
          Pool : userPool
      };
      var cognitoUser  = new AWS.CognitoIdentityServiceProvider.CognitoUser(userData);
  
      var refreshToken = localStorage.getItem('refreshToken'); 
  
      cognitoUser.getSession(function(err, session) {
          if (err) {                
              res.send(err);
          }
          else{
                  /* Session Refresh */
                  cognitoUser.refreshSession(refreshToken, (err, session) =&gt; {
  
                      if (err) {//throw err;
                          console.log('In the err'+err);
                      }
                      else{
                          var regsmar_apiKey = session.idToken.jwtToken; // will this provide new IdToken?
                          localStorage.setItem('api_key',regsmar_apiKey);
                      }
                  }); 
          }
      });
  }
  </code></pre>
  
  <p>Can any one please help me out there how should I update IdToken after expire?</p>