Last active
May 16, 2016 15:28
-
-
Save mkorman/43e510799ebe92c4378e4cadfa3f8865 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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