public static IMvcAuthenticator MvcAuthenticator(XeroApiSettings applicationSettings) { if (_authenticator != null) { return(_authenticator); } // Set up some token stores to hold request and access tokens var accessTokenStore = new MemoryTokenStore(); var requestTokenStore = new MemoryTokenStore(); // Set the application settings with an authenticator relevant to your app type switch (applicationSettings.AppType) { case XeroApiAppType.Public: _authenticator = new PublicMvcAuthenticator(requestTokenStore, accessTokenStore); break; case XeroApiAppType.Partner: _authenticator = new PartnerMvcAuthenticator(requestTokenStore, accessTokenStore); break; case XeroApiAppType.Private: throw new ApplicationException("MVC cannot be used with private applications."); default: throw new ApplicationException("Unknown app type."); } return(_authenticator); }
static XeroApiHelper() { var config = new ConfigurationBuilder() .AddJsonFile("appsettings.json") .Build(); var apiSettings = config.GetSection("XeroApi"); //Are you using a partner app? var isPartnerApp = bool.Parse(apiSettings["IsPartnerApp"]); // Set up some token stores to hold request and access tokens var accessTokenStore = new MemoryTokenStore(); var requestTokenStore = new MemoryTokenStore(); // Set the application settings with an authenticator relevant to your app type if (isPartnerApp) { Authenticator = new PartnerMvcAuthenticator(requestTokenStore, accessTokenStore); } else { Authenticator = new PublicMvcAuthenticator(requestTokenStore, accessTokenStore); } }
public static IMvcAuthenticator MvcAuthenticator(XeroApiSettings applicationSettings) { if (_authenticator != null) { return(_authenticator); } // Set up some token stores to hold request and access tokens var accessTokenStore = new MemoryTokenStore(); var requestTokenStore = new MemoryTokenStore(); // Set the application settings with an authenticator relevant to your app type switch (applicationSettings.AppType.ToLower()) { case "public": _authenticator = new PublicMvcAuthenticator(requestTokenStore, accessTokenStore); break; case "partner": _authenticator = new PartnerMvcAuthenticator(requestTokenStore, accessTokenStore); break; case "private": throw new ApplicationException("MVC cannot be used with private applications"); case "default": throw new ApplicationException("AppType did not match one of: public, partner"); } return(_authenticator); }
/// <summary> /// Creates IXeroCoreApi for Public App. /// </summary> /// <returns>IXeroCoreApi instance</returns> private static IXeroCoreApi PublicApp() { var tokenStore = new MemoryTokenStore(); var user = new ApiUser { Identifier = Environment.MachineName }; var publicAuth = new PublicAuthenticator(tokenStore); return(new Xero.Api.Infrastructure.Applications.Public.Core(publicAuth, user) { UserAgent = "Xero API - Invoice Application Demo" }); }
public static IMvcAuthenticator MvcAuthenticator(ApplicationSettings applicationSettings) { // Set up some token stores to hold request and access tokens var accessTokenStore = new MemoryTokenStore(); var requestTokenStore = new MemoryTokenStore(); // Set the application settings with an authenticator relevant to your app type if (applicationSettings.IsPartnerApp) { Authenticator = new PartnerMvcAuthenticator(requestTokenStore, accessTokenStore); } else { Authenticator = new PublicMvcAuthenticator(requestTokenStore, accessTokenStore); } return(Authenticator); }
//private Guid? accid = new Guid(); public HomeController(MemoryTokenStore tokenStore, IXeroClient xeroClient, IAccountingApi accountingApi) { _tokenStore = tokenStore; _xeroClient = xeroClient; _accountingApi = accountingApi; }
public HomeController(MemoryTokenStore tokenStore, IXeroClient xeroClient, IHttpClientFactory httpClientFactory) { _tokenStore = tokenStore; _xeroClient = xeroClient; _httpClientFactory = httpClientFactory; }