title: How to refresh authentication.idToken with GIDSignIn or GIDAuthentication?
body: <p>UPDATE 2015-10-28 - <a href="https://developers.google.com/identity/sign-in/ios/release" rel="noreferrer">Release 2.4.0 of Google Sign-In for iOS</a> appears to have resolved this problem, with both the idToken and the accessToken being refreshed as necessary by the new <code>GIDAuthentication</code> methods <code>getTokensWithHandler:</code> and <code>refreshTokensWithHandler:</code>. <code>GIDSignIn</code> method <code>SignInSilently</code> also refreshes both tokens.
  <hr>
  I'm using AWS Mobile SDK for iOS, and I've implemented Google sign-in as a Cognito credentials provider using the <a href="https://github.com/awslabs/aws-sdk-ios-samples/tree/master/CognitoSync-Sample/Objective-C/CognitoSyncDemo" rel="noreferrer">AWS Cognito Sync sample code</a> as a basis. The sign-in (and subsequent silent sign-in) flow is working correctly and signed-in users can access AWS resources like DynamoDB as intended.</p>
  
  <p>My problem is that the <code>user.authentication.idToken</code> expires after one hour and at that point calls to AWS services fail with authentication errors. I can refresh the <code>user.authentication.accessToken</code> using</p>
  
  <pre><code>[self.googleUser.authentication refreshAccessTokenWithHandler:^(NSString *accessToken, NSError *error) {...}
  </code></pre>
  
  <p>but this doesn't update the <code>idToken</code>. I've also tried calling</p>
  
  <pre><code>[[GoogleSignIn sharedInstance] signInSilently];
  </code></pre>
  
  <p>which gives me a valid idToken the first time it is called in the session, but although it completes successfully it doesn't refresh the idToken on subsequent calls within the same session.</p>
  
  <p>I've been checking/dumping the token contents using</p>
  
  <pre><code>https://www.googleapis.com/oauth2/v1/tokeninfo?id_token=&lt;idToken&gt;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=&lt;accessToken&gt;
  </code></pre>
  
  <p>I'm not sure whether the problem is that GIDSignIn is not updating idToken, or that AWS should be using the refreshToken somehow to auto-refresh the user at the backend. Either way I'm out of ideas.</p>
  
  <p>Code snippets below. I've tested using GoogleSignIn 2.2.0 and 2.3.2 and experienced the same problem.</p>
  
  <pre><code>...
  @interface MySignInClass &lt;GIDSignInDelegate&gt;
  ...
  -(void) signInWithGoogle
  {
      GIDSignIn *signIn = [GIDSignIn sharedInstance];
      signIn.clientID = MY_GOOGLE_CLIENT_ID;
      signIn.shouldFetchBasicProfile = YES;
      signIn.scopes = [NSArray arrayWithObjects:@"https://www.googleapis.com/auth/userinfo.profile", @"openid", nil];
      signIn.delegate = self;
      if([signIn hasAuthInKeychain]) {
          [signIn signInSilently];
      } else {
          [signIn signIn];
      }
  }
  ...
  - (void)signIn:(GIDSignIn *)signIn 
      didSignInForUser:(GIDGoogleUser *)user
             withError:(NSError *)error 
  {
      if (error != nil) {
          [self handleSignInError:error]; // Handle error
      }
      else {
          NSString *idToken = user.authentication.idToken;
          NSDictionary* logins = @{@"accounts.google.com": idToken};
          self.credentialsProvider = [[AWSCognitoCredentialsProvider alloc] 
             initWithRegionType:MY_COGNITO_REGION_TYPE
                     identityId:nil
                 identityPoolId:MY_COGNITO_IDENTITY_POOL
                         logins:logins];
         AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] 
              initWithRegion:MY_COGNITO_REGION                                                              
         credentialsProvider:self.credentialsProvider];
         AWSServiceManager.defaultServiceManager.defaultServiceConfiguration = configuration;
         // AWSTask stuff removed for simplicity
         AWSTask* task = [self.credentialsProvider getIdentityId];
         ...
      }
  }
  ...
  - (void)signIn:(GIDSignIn *)signIn
       didDisconnectWithUser:(GIDGoogleUser *)user
                   withError:(NSError *)error 
  {
      [self handleGoogleSignout]; // Do signout stuff
  }
  ...
  </code></pre>