title: google oauth2 get token javascript post request
body: <p>I saw some questions and answers about this but couldn't understand what to do.
  I get this error: <code>XMLHttpRequest cannot load https://accounts.google.com/o/oauth2/token. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:63342' is therefore not allowed access. The response had HTTP status code 400.</code>
  As I saw from previous posts, this is because I can't make an HTTP POST request to another server. I saw some things about using jsonp but couldn't understand how..
  This is the function I use to send the request:</p>
  
  <pre><code>var url = 'https://accounts.google.com/o/oauth2/token';
  var payload = {
      grant_type: 'authorization_code',
      code: authResult['code'],
      client_id: clientID,
      client_secret: clientSecret,
      redirect_uri: '',
      dataType: 'jsonp'
  };
  
  $.post(url, {
      form: payload
  }, function(error, response, body) {
      console.log(body);
  });
  </code></pre>