Skip to content

Instantly share code, notes, and snippets.

@khamidou
Forked from CiprianPorumbescu/NylasAuthResponse.cs
Last active August 29, 2015 14:28
Show Gist options
  • Save khamidou/4d65d75c35810e6e3bb3 to your computer and use it in GitHub Desktop.
Save khamidou/4d65d75c35810e6e3bb3 to your computer and use it in GitHub Desktop.
An example of how to authorize Nylas from .Net
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