title: XMLHttpRequest cannot load https://accounts.google.com/o/oauth2/token, Angularjs
body: <p>I can't find the solution for my problem. I'm trying to get google access token over OAuth 2.0 but I can't make my post method work. This is my code:</p>
  
  <pre><code>function oauthCallback(url) {
          var code,
              obj, request;
          if (url.indexOf("code=") &gt; 0) {
              code = url.substr(url.indexOf('=') + 1);
              request = $http({
                  method: "POST",
                  url: GOOGLE_TOKEN_URL,
                  headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                  data: 'code=' + code + '&amp;client_id=' + googleClientID + '&amp;client_secret=' + googleClientSecret + '&amp;redirect_uri=' + redirectURI + '&amp;grant_type=authorization_code'
              });
              request.success( function(data) {
                  tokenStore['googleToken'] = data.access_token;
              });
              request.error( function(data, status, headers, config) {
                  alert('failed!')
              });
              deferredLogin.resolve();
          } else if (url.indexOf("error=") &gt; 0) {;
              deferredLogin.reject(obj);
          } else {
              deferredLogin.reject({error: 'error occured', error_description: 'Unknown', error_reason: "Unknown"});
          }
      }
  </code></pre>
  
  <p>Using postman I've got access_token so the url and the data is correct. I've tried <a href="https://stackoverflow.com/questions/19254029/angularjs-http-post-does-not-send-data">this</a> and jsonp and many other answers but I always get the same result:</p>
  
  <blockquote>
    <p>XMLHttpRequest cannot load <a href="https://accounts.google.com/o/oauth2/token" rel="nofollow noreferrer">https://accounts.google.com/o/oauth2/token</a>. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin <code>'http://localhost:63342'</code> is therefore not allowed access.</p>
  </blockquote>
  
  <p>What am I doing wrong?</p>