Exemplo n.º 1
0
 /// <summary>
 /// Instantiates a new AuthRepository
 /// </summary>
 /// <param name="boxConfig">The Box configuration that should be used</param>
 /// <param name="boxService">The Box service that will be used to make the requests</param>
 /// <param name="converter">How requests/responses will be serialized/deserialized respectively</param>
 /// <param name="session">The current authenticated session</param>
 public AuthRepository(IBoxConfig boxConfig, IBoxService boxService, IBoxConverter converter, OAuthSession session)
 {
     _config = boxConfig;
     _service = boxService;
     _converter = converter;
     Session = session;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Instantiates the base class for the Box resource managers
 /// </summary>
 /// <param name="config"></param>
 /// <param name="service"></param>
 /// <param name="converter"></param>
 /// <param name="auth"></param>
 public BoxResourceManager(IBoxConfig config, IBoxService service, IBoxConverter converter, IAuthRepository auth)
 {
     _config    = config;
     _service   = service;
     _converter = converter;
     _auth      = auth;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Instantiates a new AuthRepository
 /// </summary>
 /// <param name="boxConfig">The Box configuration that should be used</param>
 /// <param name="boxService">The Box service that will be used to make the requests</param>
 /// <param name="converter">How requests/responses will be serialized/deserialized respectively</param>
 /// <param name="session">The current authenticated session</param>
 public AuthRepository(IBoxConfig boxConfig, IBoxService boxService, IBoxConverter converter, OAuthSession session)
 {
     _config    = boxConfig;
     _service   = boxService;
     _converter = converter;
     Session    = session;
 }
        public BoxResourceManagerTestIntegration()
        {
            _auth = new OAuthSession("HrMywfaXCtAStbY9FTvoCbMZCBPeBgud", "Qx34izsfUuvbcm90x88gPs6ZiRXexxN3jbQGqNoY2r9to6mppRBoCD4iqlSVrm0F", 3600, "bearer");

            _handler = new HttpRequestHandler();
            _parser = new BoxJsonConverter();
            _config = new BoxConfig(ClientId, ClientSecret, RedirectUri);
            _client = new BoxClient(_config, _auth);
        }
Exemplo n.º 5
0
        public BoxResourceManagerTestIntegration()
        {
            _auth = new OAuthSession("YOUR_ACCESS_TOKEN", "YOUR_REFRESH_TOKEN", 3600, "bearer");

            _handler = new HttpRequestHandler();
            _parser  = new BoxJsonConverter();
            _config  = new BoxConfig(ClientId, ClientSecret, RedirectUri);
            _client  = new BoxClient(_config, _auth);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Initializes a new BoxClient with the provided config, converter, service and auth objects.
        /// </summary>
        /// <param name="boxConfig">The config object to use</param>
        /// <param name="boxConverter">The box converter object to use</param>
        /// <param name="boxService">The box service to use</param>
        /// <param name="auth">The auth repository object to use</param>
        public BoxClient(IBoxConfig boxConfig, IBoxConverter boxConverter, IBoxService boxService, IAuthRepository auth)
        {
            Config     = boxConfig;
            Auth       = auth;
            _converter = boxConverter;
            _service   = boxService;

            InitManagers();
        }
Exemplo n.º 7
0
 /// <summary>
 /// Instantiates the base class for the Box resource managers
 /// </summary>
 /// <param name="config"></param>
 /// <param name="service"></param>
 /// <param name="converter"></param>
 /// <param name="auth"></param>
 public BoxResourceManager(IBoxConfig config, IBoxService service, IBoxConverter converter, IAuthRepository auth, string asUser, bool?suppressNotifications)
 {
     _config                = config;
     _service               = service;
     _converter             = converter;
     _auth                  = auth;
     _asUser                = asUser;
     _suppressNotifications = suppressNotifications;
 }
        public BoxResourceManagerTestIntegration()
        {
            _auth = new OAuthSession("YOUR_ACCESS_TOKEN", "YOUR_REFRESH_TOKEN", 3600, "bearer");

            _handler = new HttpRequestHandler();
            _parser = new BoxJsonConverter();
            _config = new BoxConfig(ClientId, ClientSecret, RedirectUri);
            _client = new BoxClient(_config, _auth);
        }
        public BoxPlatformService(IOptions <BoxPlatformServiceOptions> boxOptions, IDistributedCache distributedCache, ILogger <BoxPlatformService> logger)
        {
            _boxOptions       = boxOptions;
            _distributedCache = distributedCache;
            _logger           = logger;

            _boxConfig  = BoxConfig.CreateFromJsonString(_boxOptions.Value.BoxConfig);
            _boxJWTAuth = new BoxJWTAuth(_boxConfig);
        }
        public BoxResourceManagerTestIntegration()
        {
            _auth = new OAuthSession("HrMywfaXCtAStbY9FTvoCbMZCBPeBgud", "Qx34izsfUuvbcm90x88gPs6ZiRXexxN3jbQGqNoY2r9to6mppRBoCD4iqlSVrm0F", 3600, "bearer");

            _handler = new HttpRequestHandler();
            _parser  = new BoxJsonConverter();
            _config  = new BoxConfig(ClientId, ClientSecret, RedirectUri);
            _client  = new BoxClient(_config, _auth);
        }
Exemplo n.º 11
0
        public void SetConfig()
        {
            var environments = BoxHome.GetBoxEnvironments();
            var defaultEnv   = environments.GetDefaultEnvironment();

            if (defaultEnv.HasInLinePrivateKey)
            {
                using (FileStream fs = new FileStream(defaultEnv.BoxConfigFilePath, FileMode.Open))
                {
                    BoxPlatformConfig            = BoxCLIConfig.CreateFromJsonFile(fs);
                    BoxService.BoxPlatformConfig = BoxPlatformConfig;
                }
            }
            else if (!string.IsNullOrEmpty(defaultEnv.PrivateKeyPath))
            {
                var config = BoxPlatformUtilities.ParseBoxConfig(File.ReadAllText(defaultEnv.BoxConfigFilePath));
                var pem    = File.ReadAllText(defaultEnv.PrivateKeyPath);
                BoxPlatformConfig = new BoxCLIConfig(config.AppSettings.ClientId, config.AppSettings.ClientSecret,
                                                     config.EnterpriseId, pem, config.AppSettings.AppAuth.Passphrase,
                                                     config.AppSettings.AppAuth.PublicKeyId);
                BoxService.BoxPlatformConfig = BoxPlatformConfig;
            }
            else
            {
                // Logic to revalidate existing environments to add new detectable fields added to the model.
                // Could come in handy when introducing breaking changes to environment file model.
                var existing = environments.RevalidateExistingConfigFile(defaultEnv.BoxConfigFilePath, defaultEnv.PrivateKeyPath);
                existing.Name = defaultEnv.Name;
                if (!environments.UpdateEnvironment(existing, defaultEnv.Name))
                {
                    throw new Exception($"An error occurred with your environment. Try deleting the environment {defaultEnv.Name} and adding again.");
                }
                if (existing.HasInLinePrivateKey)
                {
                    using (FileStream fs = new FileStream(existing.BoxConfigFilePath, FileMode.Open))
                    {
                        BoxPlatformConfig            = BoxCLIConfig.CreateFromJsonFile(fs);
                        BoxService.BoxPlatformConfig = BoxPlatformConfig;
                    }
                }
                else if (!string.IsNullOrEmpty(existing.PrivateKeyPath))
                {
                    var config = BoxPlatformUtilities.ParseBoxConfig(File.ReadAllText(existing.BoxConfigFilePath));
                    var pem    = File.ReadAllText(existing.PrivateKeyPath);
                    BoxPlatformConfig = new BoxCLIConfig(config.AppSettings.ClientId, config.AppSettings.ClientSecret,
                                                         config.EnterpriseId, pem, config.AppSettings.AppAuth.Passphrase,
                                                         config.AppSettings.AppAuth.PublicKeyId);
                    BoxService.BoxPlatformConfig = BoxPlatformConfig;
                }
                else
                {
                    throw new Exception("An unknown error occured.");
                }
            }
        }
Exemplo n.º 12
0
        private static IBoxConfig ConfigureBoxApi()
        {
            IBoxConfig config = null;

            using (var fs = new FileStream(@"YOUR_JSON_FILE_HERE", FileMode.Open))
            {
                config = BoxConfigBuilder.CreateFromJsonFile(fs).Build();
            }

            return(config);
        }
Exemplo n.º 13
0
        public static IBoxConfig ConfigureBoxApi()
        {
            IBoxConfig config = null;

            using (FileStream fs = new FileStream(Config.PathToConfigFile, FileMode.Open))
            {
                config = BoxConfig.CreateFromJsonFile(fs);
            }

            return(config);
        }
        private static BoxJWTAuth GetBoxSession(IConfigurationRoot config)
        {
            IBoxConfig boxConfig  = null;
            var        configJson = config[BOX_CONFIG_KEY];

            boxConfig = BoxConfig.CreateFromJsonString(configJson);

            var session = new BoxJWTAuth(boxConfig);

            return(session);
        }
Exemplo n.º 15
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;

            _handler   = new HttpRequestHandler();
            _converter = new BoxJsonConverter();
            _service   = new BoxService(_handler);
            Auth       = new AuthRepository(Config, _service, _converter, authSession);

            InitManagers();
        }
Exemplo n.º 16
0
        /// <summary>
        /// Initializes a new BoxClient with the provided config, converter, service and auth objects.
        /// </summary>
        /// <param name="boxConfig">The config object to use</param>
        /// <param name="boxConverter">The box converter object to use</param>
        /// <param name="boxService">The box service to use</param>
        /// <param name="auth">The auth repository object to use</param>
        public BoxClient(IBoxConfig boxConfig, IBoxConverter boxConverter, IRequestHandler requestHandler, IBoxService boxService, IAuthRepository auth)
        {
            Config = boxConfig;

            _handler   = requestHandler;
            _converter = boxConverter;
            _service   = boxService;
            Auth       = auth;

            InitManagers();
        }
Exemplo n.º 17
0
        /// <summary>
        /// Instantiates a BoxClient that uses JWT authentication
        /// </summary>
        /// <param name="boxConfig">The config object to be used</param>
        /// <param name="authRepository">An IAuthRepository that knows how to retrieve new tokens using JWT</param>
        public BoxClient(IBoxConfig boxConfig, IAuthRepository authRepository)
        {
            Config = boxConfig;

            _handler   = new HttpRequestHandler();
            _converter = new BoxJsonConverter();
            _service   = new BoxService(_handler);
            Auth       = authRepository;

            InitManagers();
        }
Exemplo n.º 18
0
        private static IBoxConfig ConfigureBoxApi()
        {
            IBoxConfig config = null;

            using (FileStream fs = new FileStream(@"<YOUR_JSON_FILE_HERE>", FileMode.Open))
            {
                config = BoxConfig.CreateFromJsonFile(fs);
            }

            return(config);
        }
        public BoxResourceManagerTestIntegration()
        {
            _auth = new OAuthSession("YOUR_ACCESS_TOKEN", "YOUR_REFRESH_TOKEN", 3600, "bearer");

            _handler = new HttpRequestHandler();
            _parser  = new BoxJsonConverter();
            _config  = new BoxConfig(ClientId, ClientSecret, RedirectUri);
            _client  = new BoxClient(_config, _auth);

            _boxDeveloperEditionConfig = new BoxConfig(EnterpriseId, "enterprise", ClientId, ClientSecret, PrivateKey, PrivateKeyPassword);
            _boxDeveloperEditionClient = new BoxClient(_boxDeveloperEditionConfig);
        }
Exemplo n.º 20
0
        public BoxJWTAuth(IBoxConfig boxConfig)
        {
            this.boxConfig = boxConfig;

            var pwf = new PEMPasswordFinder(this.boxConfig.JWTPrivateKeyPassword);
            AsymmetricCipherKeyPair key;
            using (var reader = new StringReader(this.boxConfig.JWTPrivateKey))
            {
                key = (AsymmetricCipherKeyPair)new PemReader(reader, pwf).ReadObject();
            }
            this.credentials = DotNetUtilities.ToRSA((RsaPrivateCrtKeyParameters)key.Private);
        }
        public BoxResourceManagerTestIntegration()
        {
            _auth = new OAuthSession("YOUR_ACCESS_TOKEN", "YOUR_REFRESH_TOKEN", 3600, "bearer");

            _handler = new HttpRequestHandler();
            _parser = new BoxJsonConverter();
            _config = new BoxConfig(ClientId, ClientSecret, RedirectUri);
            _client = new BoxClient(_config, _auth);

            _boxDeveloperEditionConfig = new BoxConfig(EnterpriseId, "enterprise", ClientId, ClientSecret, PrivateKey, PrivateKeyPassword);
            _boxDeveloperEditionClient = new BoxClient(_boxDeveloperEditionConfig);
        }
Exemplo n.º 22
0
        public BoxJWTAuth(IBoxConfig boxConfig)
        {
            this.boxConfig = boxConfig;

            var pwf = new PEMPasswordFinder(this.boxConfig.JWTPrivateKeyPassword);
            AsymmetricCipherKeyPair key;

            using (var reader = new StringReader(this.boxConfig.JWTPrivateKey))
            {
                key = (AsymmetricCipherKeyPair) new PemReader(reader, pwf).ReadObject();
            }
            this.credentials = DotNetUtilities.ToRSA((RsaPrivateCrtKeyParameters)key.Private);
        }
Exemplo n.º 23
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();
        }
Exemplo n.º 24
0
        /// <summary>
        /// Instantiates a BoxClient with the provided config object
        /// </summary>
        /// <param name="boxConfig">The config object to be used</param>
        /// <param name="asUser">The user ID to set as the 'As-User' header parameter; used to make calls in the context of a user using an admin token</param>
        public BoxClient(IBoxConfig boxConfig, string asUser = null)
        {
            Config = boxConfig;

            _asUser = asUser;

            _handler   = new HttpRequestHandler();
            _converter = new BoxJsonConverter();
            _service   = new BoxService(_handler);
            Auth       = new AuthRepository(Config, _service, _converter, null);

            InitManagers();
        }
Exemplo n.º 25
0
        /// <summary>
        /// Constructor for JWT authetication
        /// </summary>
        /// <param name="boxConfig">Config contains information about client id, client secret, enterprise id, private key, private key password, public key id </param>
        public BoxJWTAuth(IBoxConfig boxConfig)
        {
            this.boxConfig = boxConfig;

            var pwf = new PEMPasswordFinder(this.boxConfig.JWTPrivateKeyPassword);
            AsymmetricCipherKeyPair key;
            using (var reader = new StringReader(this.boxConfig.JWTPrivateKey))
            {
                key = (AsymmetricCipherKeyPair)new PemReader(reader, pwf).ReadObject();
            }
            var rsa = DotNetUtilities.ToRSA((RsaPrivateCrtKeyParameters)key.Private);

            this.credentials = new SigningCredentials(new RsaSecurityKey(rsa), SecurityAlgorithms.RsaSha256Signature, SecurityAlgorithms.Sha256Digest);
        }
Exemplo n.º 26
0
        /// <summary>
        /// Initializes a new BoxClient with the provided config, converter, service and auth objects.
        /// </summary>
        /// <param name="boxConfig">The config object to use</param>
        /// <param name="boxConverter">The box converter object to use</param>
        /// <param name="requestHandler">The box request handler to use</param>
        /// <param name="boxService">The box service to use</param>
        /// <param name="auth">The auth repository object to use</param>
        /// <param name="asUser">The user ID to set as the 'As-User' header parameter; used to make calls in the context of a user using an admin token</param>
        /// <param name="suppressNotifications">Whether or not to suppress both email and webhook notifications. Typically used for administrative API calls. Your application must have “Manage an Enterprise” scope, and the user making the API calls is a co-admin with the correct "Edit settings for your company" permission.</param>
        public BoxClient(IBoxConfig boxConfig, IBoxConverter boxConverter, IRequestHandler requestHandler, IBoxService boxService, IAuthRepository auth, string asUser = null, bool?suppressNotifications = null)
        {
            Config = boxConfig;

            _asUser = asUser;
            _suppressNotifications = suppressNotifications;

            _handler   = requestHandler;
            _converter = boxConverter;
            _service   = boxService;
            Auth       = auth;

            InitManagers();
        }
Exemplo n.º 27
0
        /// <summary>
        /// Instantiates a BoxClient that uses JWT authentication
        /// </summary>
        /// <param name="boxConfig">The config object to be used</param>
        /// <param name="authRepository">An IAuthRepository that knows how to retrieve new tokens using JWT</param>
        /// <param name="asUser">The user ID to set as the 'As-User' header parameter; used to make calls in the context of a user using an admin token</param>
        /// <param name="suppressNotifications">Whether or not to suppress both email and webhook notifications. Typically used for administrative API calls. Your application must have “Manage an Enterprise” scope, and the user making the API calls is a co-admin with the correct "Edit settings for your company" permission.</param>
        public BoxClient(IBoxConfig boxConfig, IAuthRepository authRepository, string asUser = null, bool?suppressNotifications = null)
        {
            Config = boxConfig;

            _asUser = asUser;
            _suppressNotifications = suppressNotifications;

            _handler   = new HttpRequestHandler();
            _converter = new BoxJsonConverter();
            _service   = new BoxService(_handler);
            Auth       = authRepository;

            InitManagers();
        }
Exemplo n.º 28
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>
        /// <param name="asUser">The user ID to set as the 'As-User' header parameter; used to make calls in the context of a user using an admin token</param>
        /// <param name="suppressNotifications">Whether or not to suppress both email and webhook notifications. Typically used for administrative API calls. Your application must have “Manage an Enterprise” scope, and the user making the API calls is a co-admin with the correct "Edit settings for your company" permission.</param>
        public BoxClient(IBoxConfig boxConfig, OAuthSession authSession, string asUser = null, bool?suppressNotifications = null)
        {
            Config = boxConfig;

            _asUser = asUser;
            _suppressNotifications = suppressNotifications;

            _handler   = new HttpRequestHandler(boxConfig.WebProxy);
            _converter = new BoxJsonConverter();
            _service   = new BoxService(_handler);
            Auth       = new AuthRepository(Config, _service, _converter, authSession);

            InitManagers();
        }
Exemplo n.º 29
0
        private static void GetUser(IBoxConfig config, BoxClient boxClient)
        {
            Console.WriteLine("Enter an email\n");
            string UserEmail       = Console.ReadLine();
            var    enterpriseusers = boxClient.UsersManager.GetEnterpriseUsersAsync(filterTerm: UserEmail);

            if (enterpriseusers.Result.Entries.Count >= 1)
            {
                Console.WriteLine($"One or more Box users are found with {UserEmail}\n ");
            }
            else if (enterpriseusers.Result.Entries.Count == 0)
            {
                InviteUser(UserEmail, config, boxClient);
            }
        }
Exemplo n.º 30
0
        public BoxJWTAuth(IBoxConfig boxConfig)
        {
            this.boxConfig = boxConfig;

            var pwf = new PEMPasswordFinder(this.boxConfig.JWTPrivateKeyPassword);
            AsymmetricCipherKeyPair key;

            using (var reader = new StringReader(this.boxConfig.JWTPrivateKey))
            {
                key = (AsymmetricCipherKeyPair) new PemReader(reader, pwf).ReadObject();
            }
            var rsa = DotNetUtilities.ToRSA((RsaPrivateCrtKeyParameters)key.Private);

            this.credentials = new SigningCredentials(new RsaSecurityKey(rsa), SecurityAlgorithms.RsaSha256Signature, SecurityAlgorithms.Sha256Digest);
        }
Exemplo n.º 31
0
        //ToDo: change to accept the token or userId as parameter based on the windows authenticated user making the call
        private void CreateBoxClient()
        {
            IBoxConfig config = null;

            using (FileStream fs = new FileStream("CONFIG.JSON", FileMode.Open))
            {
                config = BoxConfig.CreateFromJsonFile(fs);
            }

            var userId    = "3420422604";
            var session   = new BoxJWTAuth(config);
            var userToken = session.UserToken(userId);

            boxClient = session.UserClient(userToken, userId);
        }
Exemplo n.º 32
0
        /// <summary>
        /// Constructor for JWT authentication
        /// </summary>
        /// <param name="boxConfig">Config contains information about client id, client secret, enterprise id, private key, private key password, public key id </param>
        public BoxJWTAuth(IBoxConfig boxConfig)
        {
            this.boxConfig = boxConfig;

            // the following allows creation of a BoxJWTAuth object without valid keys but with a valid JWT UserToken
            // this allows code like this:

            // var boxConfig = new BoxConfig("", "", "", "", "", "");
            // var boxJwt = new BoxJWTAuth(boxConfig);
            // const string userToken = "TOKEN_OBTAINED_BY_CALLING_FULL_BOXJWTAUTH";  // token valid for 1 hr.
            // UserClient = boxJwt.UserClient(userToken, null);  // this user client can do normal file operations.

            if (!string.IsNullOrEmpty(boxConfig.JWTPrivateKey) && !string.IsNullOrEmpty(boxConfig.JWTPrivateKeyPassword))
            {
                var    pwf = new PEMPasswordFinder(this.boxConfig.JWTPrivateKeyPassword);
                object key = null;
                using (var reader = new StringReader(this.boxConfig.JWTPrivateKey))
                {
                    var privateKey = new PemReader(reader, pwf).ReadObject();

                    key = privateKey;
                }

                if (key == null)
                {
                    throw new BoxException("Invalid private key!");
                }

                RSA rsa = null;
                if (key is AsymmetricCipherKeyPair)
                {
                    var ackp = (AsymmetricCipherKeyPair)key;
                    rsa = DotNetUtilities.ToRSA((RsaPrivateCrtKeyParameters)ackp.Private);
                }
                else if (key is RsaPrivateCrtKeyParameters)
                {
                    var rpcp = (RsaPrivateCrtKeyParameters)key;
                    rsa = DotNetUtilities.ToRSA(rpcp);
                }

#if NETSTANDARD1_4
                this.credentials = new SigningCredentials(new RsaSecurityKey(rsa), SecurityAlgorithms.RsaSha256);
#else
                this.credentials = new SigningCredentials(new RsaSecurityKey(rsa), SecurityAlgorithms.RsaSha256Signature, SecurityAlgorithms.Sha256Digest);
#endif
            }
        }
Exemplo n.º 33
0
        private static void InviteUser(string UserEmail, IBoxConfig config, BoxClient boxClient)
        {
            Console.WriteLine($"🔰 Initiate User invite...");
            var inviteEmail = new BoxActionableByRequest()
            {
                Login = UserEmail
            };
            var inviteId = new BoxRequestEntity()
            {
                Id = config.EnterpriseId, Type = new BoxType()
            };

            boxClient.UsersManager.InviteUserToEnterpriseAsync(new BoxUserInviteRequest()
            {
                Enterprise = inviteId, ActionableBy = inviteEmail
            });
            Console.WriteLine($"🏁 User invited to enterprise account");
        }
Exemplo n.º 34
0
        public BoxResourceManagerTestIntegration()
        {
            _handler = new HttpRequestHandler();
            _parser  = new BoxJsonConverter();

            if (userToken == null)
            {
                // Legacy way of getting the token
                _auth = new OAuthSession("YOUR_ACCESS_TOKEN", "YOUR_REFRESH_TOKEN", 3600, "bearer");

                _config = new BoxConfig(ClientId, ClientSecret, RedirectUri);
                _client = new BoxClient(_config, _auth);
            }
            else
            {
                _config = BoxConfig.CreateFromJsonString(jsonConfig);

                _client = userClient;
                _auth   = new OAuthSession(userToken, "", 3600, "bearer");
            }
        }
Exemplo n.º 35
0
        static void test_app_mycapp_2()
        {
            IBoxConfig config = null;

            using (FileStream fs = new FileStream("87881712_nqkf95rj_config.json", FileMode.Open))
            {
                config = BoxConfig.CreateFromJsonFile(fs);
            }

            var boxJWT = new BoxJWTAuth(config);

            var adminToken  = boxJWT.AdminToken();
            var adminClient = boxJWT.AdminClient(adminToken);
            var user_info   = adminClient.UsersManager.GetCurrentUserInformationAsync().Result;
            var items       = adminClient.FoldersManager.GetFolderItemsAsync("0", 100).Result;
            var users       = adminClient.UsersManager.GetEnterpriseUsersAsync().Result;

            user_info = adminClient.UsersManager.GetUserInformationAsync("224172711").Result;

            var client_token = boxJWT.UserToken("224172711");
            var client       = boxJWT.UserClient(client_token, "224172711");

            items = client.FoldersManager.GetFolderItemsAsync("0", 100).Result;
        }
Exemplo n.º 36
0
 /// <summary>
 /// Instantiates a BoxClient with the provided config object
 /// </summary>
 /// <param name="boxConfig">The config object to be used</param>
 public BoxClient(IBoxConfig boxConfig) : this(boxConfig, null) { }
Exemplo n.º 37
0
 /// <summary>
 /// Instantiates a new AuthRepository
 /// </summary>
 /// <param name="boxConfig">The Box configuration that should be used</param>
 /// <param name="boxService">The Box service that will be used to make the requests</param>
 /// <param name="converter">How requests/responses will be serialized/deserialized respectively</param>
 public AuthRepository(IBoxConfig boxConfig, IBoxService boxService, IBoxConverter converter) : this(boxConfig, boxService, converter, null)
 {
 }
Exemplo n.º 38
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BoxSharedItemsManager"/> class.
 /// </summary>
 /// <param name="config">The config object to use</param>
 /// <param name="service">The Box service object</param>
 /// <param name="converter">The box converter object to use</param>
 /// <param name="auth">The auth repository object to use</param>
 /// <param name="asUser">The user ID to set as the 'As-User' header parameter; used to make calls in the context of a user using an admin token</param>
 /// <param name="suppressNotifications">Whether or not to suppress both email and webhook notifications. Typically used for administrative API calls. Your application must have “Manage an Enterprise” scope, and the user making the API calls is a co-admin with the correct "Edit settings for your company" permission.</param>
 public BoxSharedItemsManager(IBoxConfig config, IBoxService service, IBoxConverter converter, IAuthRepository auth, string asUser = null, bool?suppressNotifications = null)
     : base(config, service, converter, auth, asUser, suppressNotifications)
 {
 }
 public BoxFilesManager(IBoxConfig config, IBoxService service, IBoxConverter converter, IAuthRepository auth)
     : base(config, service, converter, auth) { }
 public BoxCommentsManager(IBoxConfig config, IBoxService service, IBoxConverter converter, IAuthRepository auth, string asUser = null)
     : base(config, service, converter, auth, asUser) { }
 public BoxMetadataManager(IBoxConfig config, IBoxService service, IBoxConverter converter, IAuthRepository auth)
     : base(config, service, new BoxMetadataJsonConverter(), auth) { }
Exemplo n.º 42
0
 public BoxCollectionsManager(IBoxConfig config, IBoxService service, IBoxConverter converter, IAuthRepository auth, string asUser = null, bool? suppressNotifications = null)
     : base(config, service, converter, auth, asUser, suppressNotifications) { }
Exemplo n.º 43
0
 /// <summary>
 /// Instantiates a new AuthRepository
 /// </summary>
 /// <param name="boxConfig">The Box configuration that should be used</param>
 /// <param name="boxService">The Box service that will be used to make the requests</param>
 /// <param name="converter">How requests/responses will be serialized/deserialized respectively</param>
 public AuthRepository(IBoxConfig boxConfig, IBoxService boxService, IBoxConverter converter) : this(boxConfig, boxService, converter, null) { }