Default auth repository implementation that will manage the life cycle of the authentication tokens. This class can be extended to provide your own token management implementation by overriding the virtual methods
Inheritance: IAuthRepository
Example #1
0
        public static BoxClient GetClient(OAuthSession session)
        {
            var handler = new BoxHttpRequestHandler();
            var converter = new BoxJsonConverter();
            var service = new BoxService(handler);
            var authRepository = new AuthRepository(Config, service, converter, session);

            var client = new BoxClient(Config, converter, handler, service, authRepository);
            return client;
        }
        public BoxResourceManagerTest()
        {
            // Initial Setup
            _converter = new BoxJsonConverter();
            _handler = new Mock<IRequestHandler>();
            _service = new BoxService(_handler.Object);
            _config = new Mock<IBoxConfig>();

            _authRepository = new AuthRepository(_config.Object, _service, _converter, new OAuthSession("fakeAccessToken", "fakeRefreshToken", 3600, "bearer"));
        }
        public async Task AuthenticateLive_InvalidAuthCode_Exception()
        {
            // Arrange
            IRequestHandler handler = new HttpRequestHandler();
            IBoxService service = new BoxService(handler);
            IBoxConfig config = new BoxConfig(null, null, null);

            IAuthRepository authRepository = new AuthRepository(config, service, _converter);

            // Act
            OAuthSession response = await authRepository.AuthenticateAsync("fakeAuthorizationCode");
        }
Example #4
0
        /// <summary>
        /// Instantiates a BoxClient with the provided config object and auth session
        /// </summary>
        /// <param name="boxConfig">The config object to be used</param>
        /// <param name="authSession">A fully authenticated auth session</param>
        public BoxClient(IBoxConfig boxConfig, OAuthSession authSession)
        {
            _config = boxConfig;
            
            IRequestHandler handler = new HttpRequestHandler();
            _converter = new BoxJsonConverter();

            _service = new BoxService(handler);

            Auth = new AuthRepository(_config, _service, _converter, authSession);

            InitManagers();
        }