title: google ExchangeCodeForTokenAsync invalid_grant in webapi
body: <p>i have implemented <a href="https://developers.google.com/identity/sign-in/web/server-side-flow#implementing_the_one-time-code_flow" rel="nofollow">GoogleAuthorizationCodeFlow</a> scenario from <a href="https://developers.google.com/api-client-library/dotnet/guide/aaa_oauth#web-applications-aspnet-mvc" rel="nofollow">google api client dotnet</a> and  tutorial to get token from what my client sent to server as a code. but when i call <code>flow.ExchangeCodeForTokenAsync</code> , I get the following error : </p>
  
  <pre><code>{"Error:\"invalid_grant\", Description:\"\", Uri:\"\""}
  </code></pre>
  
  <p>I read <a href="https://developers.google.com/analytics/devguides/config/mgmt/v3/authorization#invalid_grant" rel="nofollow">google authorization invalid_grant</a> and <a href="https://gusclass.com/blog/2014/04/16/how-to-oauth-2-0-flows-using-the-google-net-api-client-libraries-1-7-in-c/" rel="nofollow">gusclass oauth 2 using google dotnet api client libraries</a> but they didn't help me and. I think it must be very simple but I don't know why it doesn't work.
  For client side , I have used <a href="https://github.com/sahat/satellizer" rel="nofollow">Satellizer</a> and this is my server Codes:</p>
  
  <pre><code>public bool PostExchangeAccessToken(GoogleClientAccessCode code)
          {
              string[] SCOPES = { "email" };
              IAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer
              {
                  ClientSecrets = new ClientSecrets()
                  {
                      ClientSecret = "******",
                      ClientId = "********.apps.googleusercontent.com"
                  },
                  Scopes = SCOPES
              });
              try
              {
                  TokenResponse token;
                  token = flow.ExchangeCodeForTokenAsync("*****@gmail.com", Newtonsoft.Json.JsonConvert.SerializeObject(code), "https://localhost:44301/",
                                  CancellationToken.None).Result;
              }
              catch (Exception ex)
              {
                  throw ex;
              }
              return true;
          }
  </code></pre>
  
  <p>what is the problem?</p>