public ContentResult ExchangeToken() { var code = Request.Params.Get("code"); var tokenDetails = General.ExchangeToken( int.Parse(ConfigurationManager.AppSettings.Get("CREATESEND_CLIENT_ID")), ConfigurationManager.AppSettings.Get("CREATESEND_CLIENT_SECRET"), ConfigurationManager.AppSettings.Get("CREATESEND_REDIRECT_URI"), code); var accessToken = tokenDetails.access_token; var refreshToken = tokenDetails.refresh_token; var response = ""; response = "<pre>"; response += "Your user is successfully authenticated. Here are the details you need:<br/><br/>"; response += "access token: " + accessToken + "<br/>"; response += "refresh token: " + refreshToken + "<br/>"; response += "<br/><br/>"; AuthenticationDetails auth = new OAuthAuthenticationDetails( accessToken, refreshToken); General general = new General(auth); var clients = general.Clients(); response += "We've made an API call too. Here are your clients:<br/><br/>"; foreach (BasicClient c in clients) { response += c.Name + "<br/>"; } response += "</pre>"; return Content(response); }
public void GetExternalSessionURL() { var general = new General(auth); try { ExternalSessionOptions externalSessionOptions = new ExternalSessionOptions { Email = "*****@*****.**", Chrome = "None", Url = "/subscribers/[email protected]", IntegratorID = "your integratorID", ClientID = "your clientID" }; string sessionUrl = general.ExternalSessionUrl(externalSessionOptions); Console.WriteLine(string.Format("Session created and accessible at URL: {0}", sessionUrl)); } catch (CreatesendException ex) { ErrorResult error = (ErrorResult)ex.Data["ErrorResult"]; Console.WriteLine(error.Code); Console.WriteLine(error.Message); } catch (Exception ex) { // Handle some other failure Console.WriteLine(ex.ToString()); } }
public void Authorize() { var auth = new ApiKeyAuthenticationDetails(_key); var general = new General(auth); }