title: (400) Bad Request : Get AccessToken of Salesforce error:"invalid_grant"
body: <p>I'm using azure function with below code -
  everything is working fine when i run azure fucntion locally but after deployment i'm getting below error </p>
  
  <blockquote>
    <p>{"error":"invalid_grant","error_description":"authentication failure"}</p>
  </blockquote>
  
  <p>Function code - </p>
  
  <pre><code>ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.SystemDefault | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
                  HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "tokenURL");
                  var keyValues = new List&lt;KeyValuePair&lt;string, string&gt;&gt;();
                  keyValues.Add(new KeyValuePair&lt;string, string&gt;("grant_type", "password"));
                  keyValues.Add(new KeyValuePair&lt;string, string&gt;("client_id", "clientID"));
                  keyValues.Add(new KeyValuePair&lt;string, string&gt;("client_secret", "clientSecret"));
                  keyValues.Add(new KeyValuePair&lt;string, string&gt;("username", "userName"));
                  keyValues.Add(new KeyValuePair&lt;string, string&gt;("password", "password"));
  
                  request.Content = new FormUrlEncodedContent(keyValues);
                  request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
                  HttpResponseMessage response = await httpClient.SendAsync(request);
  
                      string respContent = await response.Content.ReadAsStringAsync();
                      var oauthResponse = JsonConvert.DeserializeObject&lt;Dictionary&lt;string, string&gt;&gt;(respContent);
                      string token = oauthResponse["access_token"];
  </code></pre>
  
  <blockquote>
    <p>Is there any other setting required from salesforce ?</p>
    
    <p>Modify the Connected app: (Edit Policies) Relax IP restrictions </p>
    
    <p>Permitted Usersto "All users may self-authorize"</p>
  </blockquote>