Skip to content

Instantly share code, notes, and snippets.

@mkorman
Last active May 16, 2016 15:28
Show Gist options
  • Save mkorman/43e510799ebe92c4378e4cadfa3f8865 to your computer and use it in GitHub Desktop.
Save mkorman/43e510799ebe92c4378e4cadfa3f8865 to your computer and use it in GitHub Desktop.
public void Login()
{
String jsonResponse;
using (var client = new HttpClient())
{
var request = new FormUrlEncodedContent(new Dictionary<string, string>
{
{"grant_type", "password"},
{"client_id", ClientId},
{"client_secret", ClientSecret},
{"username", Username},
{"password", Password + Token}
}
);
request.Headers.Add("X-PrettyPrint", "1");
var response = client.PostAsync(LOGIN_ENDPOINT, request).Result;
jsonResponse = response.Content.ReadAsStringAsync().Result;
}
var values = JsonConvert.DeserializeObject<Dictionary<string, string>>(jsonResponse);
AuthToken = values["access_token"];
InstanceUrl = values["instance_url"];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment