title: How to get access token for google oauth?
body: <p>I am using C# (ASP.NET). I want to use Google OAuth for accessing the user profile detail in my app. I successfully got the authorization code but having a problem in getting the access token. 
  I prefer the <a href="https://developers.google.com/accounts/docs/OAuth2WebServer" rel="nofollow noreferrer">Google tutorials</a>. In tutorial, I read that I have to send the request and get the response from google. For that, I use <code>System.Net.HttpWebRequest/HttpWebResponse</code> (am I going in the right way). I have used this code...</p>
  
  <pre><code>byte[] buffer = Encoding.ASCII.GetBytes("?code=" + code + "&amp;client_id=xxx&amp;client_secret=xxx&amp;redirect_uri=xxxx&amp;grant_type=authorization_code");
  HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://accounts.google.com");
  req.Method = "POST";
  req.ContentType = "application/x-www-form-urlencoded";
  req.ContentLength = buffer.Length;
  
  Stream strm = req.GetRequestStream();
  strm.Write(buffer, 0, buffer.Length);
  strm.Close();
  
  HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
  Response.Write(((HttpWebResponse)resp).StatusDescription);
  </code></pre>
  
  <p>But, I got the error:</p>
  
  <blockquote>
    <p>The remote server returned an error: (405) Method Not Allowed.</p>
  </blockquote>
  
  <p>Update: Here variable <code>code</code> is authorization code.</p>