Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        public AuthController(IOptions <XeroApiSettings> settings)
        {
            _user = XeroApiHelper.User();

            _authenticator = XeroApiHelper.MvcAuthenticator(settings.Value);
        }