title: Salesforce Refused to set unsafe header "User-Agent"
body: <p>I am trying to create a user login/signup on my remote app that accesses user data on Salesforce. I am doing this from javascript via Salesforce REST API. This was not working using requests straight from javascript due to CORS restrictions, so I found <a href="https://salesforce.stackexchange.com/questions/13607/how-to-call-apex-rest-api-from-javascript?rq=1">this example</a>. My code is as follows:</p>
  
  <pre><code>    var result = sforce.connection.login('example@provider.com', 'pass'+'securityToken');
      sforce.connection.init(result.sessionId, 'https://login.salesforce.com/services/oauth2/token')
  
      sforce.connection.remoteFunction({
          url: 'https://login.salesforce.com/services/oauth2/token',
          requestHeaders: {
              "Authorization" : "Bearer " +__sfdcSessionId,
              "Content-Type":"application/json",
              "Connection":"Keep-Alive"
          },
          method: "GET",
          onSuccess : function(response) {
              console.log("Success " + response)
          },
          onFailure: function(response) {
              console.log("Failed " + response)
          }
      });
  </code></pre>
  
  <p>When I run this code I get the following errors:</p>
  
  <p>1) Refused to set unsafe header "User-Agent"<br>
  2) POST http:///services/Soap/u/31.0 404 (Not Found)<br>
  3) Remote invocation failed, due to: </p>
  
  <pre><code>&lt;html&gt;&lt;head&gt;
  &lt;title&gt;404 Not Found&lt;/title&gt;
  &lt;/head&gt;&lt;body&gt;
  &lt;h1&gt;Not Found&lt;/h1&gt;
  &lt;p&gt;The requested URL /services/Soap/u/31.0 was not found on this server.&lt;/p&gt;
  &lt;/body&gt;&lt;/html&gt;
   status code: 
  </code></pre>
  
  <p>Using a code editor I can see that the errors are occurring after hitting the sforce.connection.login() script and never making it to the sforce.connection.init() script in my code.</p>
  
  <p>How do I resolve this issue so that I may log a user in from my remote web app and gain access to the user information within salesforce?</p>