Forked from CiprianPorumbescu/NylasAuthResponse.cs
Last active
August 29, 2015 14:28
-
-
Save khamidou/4d65d75c35810e6e3bb3 to your computer and use it in GitHub Desktop.
An example of how to authorize Nylas from .Net
This file contains 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 async Task<ActionResult> NylasAuthenticationResult(string code) | |
{ | |
using (HttpClient httpClient = new HttpClient()) | |
{ | |
// tried as x-www-form-encoded | |
var postData = new List<KeyValuePair<string, string>>(); | |
postData.Add(new KeyValuePair<string, string>("client_id", "cf7jhxlkkvimkxvd2vnkkzci")); | |
postData.Add(new KeyValuePair<string, string>("client_secret", "your_secret")); | |
postData.Add(new KeyValuePair<string, string>("grant_type ", "authorization_code")); | |
postData.Add(new KeyValuePair<string, string>("code ", code)); | |
HttpContent content = new FormUrlEncodedContent(postData); | |
var authorizeResponseMessage = await httpClient.PostAsync("oauth/token", content).ConfigureAwait(false); | |
var authorizeResponse = authorizeResponseMessage.Content.ReadAsAsync<NylasAuthorizeResponse>().Result; | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment