Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HttpClient client = new HttpClient();
- var tokenEndpoint = "https://login.microsoftonline.com/testdir.onmicrosoft.com/oauth2/token";
- var body = "resource=www.graph.microsoft.com&client_id=" + App.ClientId + "&grant_type=password&username=" + UsernameEntry.Text + "&password=" + PasswordEntry.Text + "";
- var stringContent = new StringContent(body, Encoding.UTF8, "application/x-www-form-urlencoded");
- var result = await client.PostAsync(tokenEndpoint, stringContent).ContinueWith<string>(response => response.Result.Content.ReadAsStringAsync().Result);
- var jobject = JObject.Parse(result);
- App.AccessToken = jobject["access_token"].Value<string>();
- tokenEndpoint = "https://login.microsoftonline.com/testdir.onmicrosoft.com/oauth2/authorize";
- body = "client_id=xxxx&response_type=code&redirect_uri=https://testapi.azurewebsites.net/";
- result = await client.PostAsync(tokenEndpoint, stringContent).ContinueWith<string>(response => response.Result.Content.ReadAsStringAsync().Result);
- jobject = JObject.Parse(result);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement