コード例 #1
0
ファイル: BoxAPI.cs プロジェクト: rbhttchr/WebAPI
        /// <summary>
        ///  Updates the accessToken and refreshToken. These keys must already exist in the Dictionary table.
        /// </summary>
        public async Task RefreshAccessTokenAsync()
        {
            try
            {
                using (var _context = CTDbContext.CreateDbContext())
                {
                    var accessToken = await _context.Dictionaries.Where(d => d.Key == CommonUtils.BOX_ACCESS_TOKEN).FirstAsync();

                    var refreshToken = await _context.Dictionaries.Where(d => d.Key == CommonUtils.BOX_REFRESH_TOKEN).FirstAsync();

                    var config = new BoxConfig(Globals.appSettings.BOX_CLIENT_ID, Globals.appSettings.BOX_CLIENT_SECRET, new Uri("http://locahost"));
                    var auth   = new OAuthSession(accessToken.Value, refreshToken.Value, 3600, "bearer");
                    var client = new BoxClient(config, auth);
                    /// Try to refresh the access token
                    auth = await client.Auth.RefreshAccessTokenAsync(auth.AccessToken);

                    /// Create the client again
                    client = new BoxClient(config, auth);
                    _logger.LogInformation("Refreshed Tokens");
                    accessToken.Value  = auth.AccessToken;
                    refreshToken.Value = auth.RefreshToken;
                    await _context.SaveChangesAsync();
                }
            }
            catch (Box.V2.Exceptions.BoxSessionInvalidatedException e)
            {
                _logger.LogError(e, "Box Token Failure.");
                await _slack.PostErrorAsync(e, "Box Token Failure.");

                throw;
            }
        }
コード例 #2
0
ファイル: BoxAPI.cs プロジェクト: rbhttchr/WebAPI
        // To generate authCode on a browser open,
        // https://account.box.com/api/oauth2/authorize?client_id=[CLIENT_ID]&response_type=code
        /// <summary>Updates Box accessToken and refreshToken values in the Dictionary table.
        /// Optionally creates these keys if they do not exist.
        /// </summary>
        public async Task CreateAccessTokenAsync(string authCode)
        {
            // This implementation is overly chatty with the database, but we rarely create access tokens so it is not a problem
            using (var _context = CTDbContext.CreateDbContext())
            {
                if (!await _context.Dictionaries.Where(d => d.Key == CommonUtils.BOX_ACCESS_TOKEN).AnyAsync())
                {
                    _context.Dictionaries.Add(new Dictionary
                    {
                        Key = CommonUtils.BOX_ACCESS_TOKEN
                    });
                    await _context.SaveChangesAsync();
                }
                if (!await _context.Dictionaries.Where(d => d.Key == CommonUtils.BOX_REFRESH_TOKEN).AnyAsync())
                {
                    _context.Dictionaries.Add(new Dictionary
                    {
                        Key = CommonUtils.BOX_REFRESH_TOKEN
                    });
                    await _context.SaveChangesAsync();
                }


                var accessToken  = _context.Dictionaries.Where(d => d.Key == CommonUtils.BOX_ACCESS_TOKEN).First();
                var refreshToken = _context.Dictionaries.Where(d => d.Key == CommonUtils.BOX_REFRESH_TOKEN).First();
                var config       = new BoxConfig(Globals.appSettings.BOX_CLIENT_ID, Globals.appSettings.BOX_CLIENT_SECRET, new Uri("http://locahost"));
                var client       = new Box.V2.BoxClient(config);
                var auth         = await client.Auth.AuthenticateAsync(authCode);

                _logger.LogInformation("Created Box Tokens");
                accessToken.Value  = auth.AccessToken;
                refreshToken.Value = auth.RefreshToken;
                await _context.SaveChangesAsync();
            }
        }
コード例 #3
0
ファイル: AuthBox.cs プロジェクト: zhangluqi/GoogleDriveDemo
        public async Task <BoxClient> GetBoxClient()
        {
            BoxClient boxClient           = null;
            Uri       uri                 = string.IsNullOrEmpty(RedirectUri) ? null : new Uri(RedirectUri);
            var       BoxAuthorizeRequest = GetAuthorizeUri(OAuthResponseType.Code, clientId, uri).ToString();

            var http = new HttpListener();

            http.Prefixes.Add(RedirectUri);
            http.Start();

            System.Diagnostics.Process.Start(BoxAuthorizeRequest);
            var context = await http.GetContextAsync();

            string code = context.Request.QueryString.Get("code");

            if (!string.IsNullOrEmpty(code))
            {
                string token = await BoxAuthAsync(code);

                if (!string.IsNullOrEmpty(token))
                {
                    var config  = new BoxConfig(clientId, secret, new Uri(RedirectUri));
                    var session = new OAuthSession(token, "NOT_NEEDED", 3600, "bearer");
                    boxClient = new BoxClient(config, session);
                }
            }
            return(boxClient);
        }
コード例 #4
0
        /// <summary>
        /// Pass teh token
        /// </summary>
        /// <param name="token"></param>
        public BoxDotComUploadService(string token)
        {
            var config  = new BoxConfig("", "", new Uri("http://localhost"));
            var session = new OAuthSession(token, "NOT_NEEDED", 3600, "bearer");

            _boxClient = new BoxClient(config, session);
        }
コード例 #5
0
        public async Task <IActionResult> UIElements()
        {
            // セッションからアクセストークン等を取り出す
            // ここはおそらくよりよい方法があるはず
            var accessToken  = HttpContext.Session.GetString("AccessToken");
            var refreshToken = HttpContext.Session.GetString("RefreshToken");
            // expiresInはそのまま利用すべきではないと思われるが・・
            var expiresIn = HttpContext.Session.GetInt32("ExpiresIn") ?? default(int);
            var tokenType = HttpContext.Session.GetString("TokenType");

            Console.WriteLine($"session accessToken {accessToken}");
            Console.WriteLine($"session refreshToken {refreshToken}");
            Console.WriteLine($"session expiresIn {expiresIn}");
            Console.WriteLine($"session tokenType {tokenType}");

            // sessionを組み立て直し
            var session = new OAuthSession(accessToken, refreshToken, expiresIn, tokenType);
            // clientをSessionを元に作成
            var config = new BoxConfig(ClientId, ClientSecret, new System.Uri(CallBackUrl));
            var client = new BoxClient(config, session);

            // 動作確認として認証したユーザーの情報を表示
            var user = await client.UsersManager.GetCurrentUserInformationAsync();

            Console.WriteLine($"Login User: Id={user.Id}, Name={user.Name}, Login={user.Login}");

            ViewBag.accessToken = accessToken;
            return(View());
        }
コード例 #6
0
        private string DeleteGroup()
        {
            var boxConfig = new BoxConfig(ClientId, ClientSecret, EntrepriseId, PrivateKey,
                                          Passphrase, JwtPublicKey);
            var boxJWT = new BoxJWTAuth(boxConfig);

            var adminToken = boxJWT.UserToken(UserId);
            var client     = boxJWT.AdminClient(adminToken);

            var groupId = GetGroupIdByGroupName(client, GroupName);

            if (groupId == null)
            {
                return("Group not found.");
            }

            var res = client.GroupsManager.DeleteAsync(groupId);

            res.Wait();
            if (res.Exception != null)
            {
                return(res.Exception.Message);
            }

            return("Success");
        }
コード例 #7
0
        private async Task ExecuteMainAsync()
        {
            Console.WriteLine("Access token: ");
            var accessToken = Console.ReadLine();

            Console.WriteLine("Remote file name: ");
            var fileName = Console.ReadLine();

            Console.WriteLine("Local file path: ");
            var localFilePath = Console.ReadLine();

            Console.WriteLine("Parent folder Id: ");
            var parentFolderId = Console.ReadLine();

            var timer = Stopwatch.StartNew();

            var auth = new OAuthSession(accessToken, "YOUR_REFRESH_TOKEN", 3600, "bearer");

            var config = new BoxConfig("YOUR_CLIENT_ID", "YOUR_CLIENT_ID", new Uri("http://boxsdk"));
            var client = new BoxClient(config, auth);

            var file        = File.OpenRead(localFilePath);
            var fileRequest = new BoxFileRequest
            {
                Name   = fileName,
                Parent = new BoxFolderRequest {
                    Id = parentFolderId
                }
            };

            var bFile = await client.FilesManager.UploadAsync(fileRequest, file);

            Console.WriteLine("{0} uploaded to folder: {1} as file: {2}", localFilePath, parentFolderId, bFile.Id);
            Console.WriteLine("Time spend : {0} ms", timer.ElapsedMilliseconds);
        }
コード例 #8
0
        static async Task MainAsync()
        {
            var enterpriseToken = boxJWTHelper.GetEnterpriseToken();
            var config          = new BoxConfig(CLIENT_ID, CLIENT_SECRET, new Uri("http://localhost"));
            var adminSession    = new OAuthSession(enterpriseToken, REFRESH_TOKEN, 3600, "bearer");

            adminClient = new BoxClient(config, adminSession);

            string appUserId   = boxJWTHelper.CreateAppUser("test user", enterpriseToken);
            var    userToken   = boxJWTHelper.GetUserToken(appUserId);
            var    userSession = new OAuthSession(userToken, REFRESH_TOKEN, 3600, "bearer");

            userClient = new BoxClient(config, userSession);

            var items = await adminClient.FoldersManager.GetFolderItemsAsync("0", 100);

            Console.WriteLine("Admin account root folder items:");
            items.Entries.ForEach((i) =>
            {
                Console.WriteLine("\t{0}", i.Name);
                if (i is BoxFile)
                {
                    Console.WriteLine("\t{0}", BoxJWTHelper.EmbedUrl(i.Id, enterpriseToken));
                }
            });

            var userDetails = await userClient.UsersManager.GetCurrentUserInformationAsync();

            Console.WriteLine("\nApp User Details:");
            Console.WriteLine("\tId: {0}", userDetails.Id);
            Console.WriteLine("\tName: {0}", userDetails.Name);
            Console.WriteLine("\tStatus: {0}", userDetails.Status);

            boxJWTHelper.DeleteAppUser(appUserId, enterpriseToken);
        }
コード例 #9
0
        public async Task <IActionResult> BoxRedirect(String code)
        {
            // AUTHコードが受け取れたか確認
            Console.WriteLine("BoxRedirect {0}", code);


            var config = new BoxConfig(ClientId, ClientSecret, new System.Uri(CallBackUrl));
            var client = new BoxClient(config);

            // AUTHコード → アクセストークンへ交換
            await client.Auth.AuthenticateAsync(code);

            var accessToken = client.Auth.Session.AccessToken;
            //var refreshToken = client.Auth.Session.RefreshToken;

            OAuthSession session = client.Auth.Session;

            HttpContext.Session.SetString("AccessToken", session.AccessToken);
            HttpContext.Session.SetString("RefreshToken", session.RefreshToken);
            HttpContext.Session.SetInt32("ExpiresIn", session.ExpiresIn);
            HttpContext.Session.SetString("TokenType", session.TokenType);

            // clientが動くかテスト
            var user = await client.UsersManager.GetCurrentUserInformationAsync();

            Console.WriteLine($"Login User: Id={user.Id}, Name={user.Name}, Login={user.Login}");

            ViewBag.accessToken = accessToken;
            return(RedirectToAction("UIElements"));
        }
コード例 #10
0
        private string DeleteUser()
        {
            var boxConfig = new BoxConfig(ClientId, ClientSecret, EntrepriseId, PrivateKey,
                                          Passphrase, JwtPublicKey);
            var boxJWT = new BoxJWTAuth(boxConfig);

            var adminToken = boxJWT.UserToken(UserId);
            var client     = boxJWT.AdminClient(adminToken);

            var usersRes = client.UsersManager.GetEnterpriseUsersAsync();

            usersRes.Wait();

            foreach (var user in usersRes.Result.Entries)
            {
                if (user.Login == UserIdToDelete)
                {
                    var delUserRes = client.UsersManager.DeleteEnterpriseUserAsync(user.Id, false, false);

                    delUserRes.Wait();

                    return("Success");
                }
            }
            return("User Not Found");
        }
コード例 #11
0
        public async Task <ICustomActivityResult> Execute()
        {
            var Message = string.Empty;

            var boxConfig   = new BoxConfig(CLIENT_ID, CLIENT_SECRET, ENTERPRISE_ID, PRIVATE_KEY, JWT_PRIVATE_KEY_PASSWORD, JWT_PUBLIC_KEY_ID);
            var boxJWT      = new BoxJWTAuth(boxConfig);
            var adminToken  = boxJWT.UserToken(USER_ID);
            var adminClient = boxJWT.AdminClient(adminToken);

            using (FileStream fileStream = new FileStream(FilePath, FileMode.Open))
            {
                BoxFileRequest requestParams = new BoxFileRequest()
                {
                    Name   = NameFile,
                    Parent = new BoxRequestEntity()
                    {
                        Id = FolderID
                    }
                };
                BoxFile file = await adminClient.FilesManager.UploadAsync(requestParams, fileStream);

                Message = file.Id;
            }
            return(this.GenerateActivityResult(Message));
        }
コード例 #12
0
        private async Task ExecuteMainAsync()
        {
            var devToken       = "E3myQeNXgY2PA5q2AQaSqLbEUIVabPeU";
            var fileName       = "test.txt";
            var localFilePath  = @"C:\Users\Public\test.txt";
            var parentFolderId = "1";

            var timer = Stopwatch.StartNew();



            var config = new BoxConfig(CLIENT_ID, CLIENT_SECRET, new Uri("http://boxsdk"));
            //DevToken
            var auth   = new OAuthSession(devToken, "NOT_NEEDED", 3600, "bearer");
            var client = new BoxClient(config, auth);

            var file        = File.OpenRead(localFilePath);
            var fileRequest = new BoxFileRequest
            {
                Name   = fileName,
                Parent = new BoxFolderRequest {
                    Id = parentFolderId
                }
            };

            var bFile = await client.FilesManager.UploadAsync(fileRequest, file);

            Console.WriteLine("{0} uploaded to folder: {1} as file: {2}", localFilePath, parentFolderId, bFile.Id);
            Console.WriteLine("Time spend : {0} ms", timer.ElapsedMilliseconds);
            Console.ReadKey();
        }
コード例 #13
0
        public static void Initialize(TestContext testContext)
        {
            jsonConfig = Environment.GetEnvironmentVariable("JSON_CONFIG");

            if (string.IsNullOrEmpty(jsonConfig))
            {
                Debug.WriteLine("No json config found!");
            }
            else
            {
                Debug.WriteLine("json config content length : " + jsonConfig.Length);

                var config  = BoxConfig.CreateFromJsonString(jsonConfig);
                var session = new BoxJWTAuth(config);

                // create a new app user
                // client with permissions to manage application users
                var adminToken = session.AdminToken();
                adminClient = session.AdminClient(adminToken);

                var user = CreateNewUser(adminClient).Result;

                userId = user.Id;

                Debug.WriteLine("New app user created : " + userId);

                // user client with access to user's data (folders, files, etc)
                userToken  = session.UserToken(userId);
                userClient = session.UserClient(userToken, userId);
            }
        }
コード例 #14
0
        private string AddUser()
        {
            var boxConfig = new BoxConfig(ClientId, ClientSecret, EntrepriseId, PrivateKey,
                                          Passphrase, JwtPublicKey);

            var boxJWT = new BoxJWTAuth(boxConfig);

            var adminToken = boxJWT.UserToken(UserId);
            var client     = boxJWT.AdminClient(adminToken);

            var userRes = client.UsersManager.CreateEnterpriseUserAsync(new BoxUserRequest()
            {
                Name  = UserName,
                Login = Login
            });

            userRes.Wait();

            if (userRes.Exception != null)
            {
                return(userRes.Exception.Message);
            }

            return("Success");
        }
コード例 #15
0
        public MainViewModel() : base()
        {
            OAuthSession session = null;

            Config = new BoxConfig(ClientId, ClientSecret, RedirectUri);
            Client = new BoxClient(Config, session);
        }
コード例 #16
0
 static void test_app_mycapp()
 {
     var config    = new BoxConfig("m4i3pi5dpz0wbanc2fm8m0ir66qyr4dh", "zCvs6w94X8tgkFce1d5RbGbiudYjfylK", new Uri("http://localhost"));
     var session   = new OAuthSession("O35fialsYuSQH1vblbaYR0K6oBY0gwK0", "NOT_NEEDED", 3600, "bearer");
     var client    = new BoxClient(config, session);
     var user_info = client.UsersManager.GetCurrentUserInformationAsync().Result;
     var items     = client.FoldersManager.GetFolderItemsAsync("0", 100).Result;
 }
コード例 #17
0
        public BoxService(BoxAuthTokenDO authToken)
        {
            var config    = new BoxConfig(BoxHelpers.ClientId, BoxHelpers.Secret, new Uri(BoxHelpers.RedirectUri));
            var expiresIn = (int)(authToken.ExpiresAt - DateTime.UtcNow).TotalSeconds;

            Box.V2.Auth.OAuthSession session = new Box.V2.Auth.OAuthSession(authToken.AccessToken, authToken.RefreshToken, expiresIn, "bearer");
            _boxClient = new BoxClient(config, session);
        }
コード例 #18
0
        private async void init()
        {
            var config = new BoxConfig(KEY, SECRET, RedirectUri);

            client = new BoxClient(config);
            // string authCode = await OAuth2Sample.GetAuthCode(config.AuthCodeUri, config.RedirectUri);
            //  await client.Auth.AuthenticateAsync(authCode);
        }
コード例 #19
0
        public void retriesWithNewJWTAssertionOnErrorResponseAndSucceeds()
        {
            var config     = new BoxConfig(ClientId, ClientSecret, EnterpriseId, privateKey, passphrase, publicKeyID);
            var session    = new BoxJWTAuth(config);
            var adminToken = session.AdminToken();

            adminClient = session.AdminClient(adminToken);
        }
コード例 #20
0
        public static BoxClient GetBoxClientWithApiKeyAndToken(string apiKey, string accessToken)
        {
            var auth      = new OAuthSession(accessToken, "NOT_USED", 3600, "bearer");
            var boxConfig = new BoxConfig(apiKey, "NOT_USED", new Uri("http://boxsdk"));
            var boxClient = new BoxClient(boxConfig, auth);

            return(boxClient);
        }
コード例 #21
0
 static void test_app_myapp0926()
 {
     var config    = new BoxConfig("ol91r17fhsvzdsnny8xgkaiy5jkgxfw8", "956pFqJsfy1Nn7yAajRhIn6eHc2eidMa", new Uri("http://localhost"));
     var session   = new OAuthSession("nHe4pvCa3BXqnVbXnjOI4xnfCjpkobBj", "NOT_NEEDED", 3600, "bearer");
     var client    = new BoxClient(config, session);
     var user_info = client.UsersManager.GetCurrentUserInformationAsync().Result;
     var items     = client.FoldersManager.GetFolderItemsAsync("0", 100).Result;
 }
        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);
        }
コード例 #23
0
        public IActionResult Index()
        {
            var config = new BoxConfig(ClientId, ClientSecret, new System.Uri(CallBackUrl));

            // 認証用URLは、文字列を連結してもいいですが、このコードで作れます。
            ViewBag.authorizationUrl = config.AuthCodeUri.ToString();
            // ViewBag.authorizationUrl = $"https://account.box.com/api/oauth2/authorize?client_id={clientId}&response_type=code";
            return(View());
        }
コード例 #24
0
        private static BoxClient CreateClientByToken(string token)
        {
            var auth = new OAuthSession(token, "YOUR_REFRESH_TOKEN", 3600, "bearer");

            var config = new BoxConfig(string.Empty, string.Empty, new Uri("http://boxsdk"));
            var client = new BoxClient(config, auth);

            return(client);
        }
コード例 #25
0
        public static async Task GenerateCards(SkillResult result, dynamic boxBody)
        {
            var boxConfig = new BoxConfig(string.Empty, string.Empty, new Uri(config.BoxApiUrl));
            var session   = new OAuthSession(boxBody.token.write.access_token.Value, string.Empty, 3600, "bearer");
            var client    = new BoxClient(boxConfig, session);

            if (client == null)
            {
                throw new Exception("Unable to create box client");
            }

            Console.WriteLine("======== BoxHelper Result =========");
            Console.WriteLine(JsonConvert.SerializeObject(result, Formatting.None));

            var cards = new List <Dictionary <string, object> >
            {
                GenerateSupportHeaderCard(result, boxBody),
                GenerateScoreKeywordCard(result, boxBody),
                GenerateTopicsKeywordCard(result, boxBody),
                GenerateScriptAdherenceKeywordCard(result, boxBody),
                GenerateTranscriptCard(result, boxBody)
            };

            cards.AddRange(GeneateSentimentTimelineCards(result, boxBody));

            Console.WriteLine("======== Cards =========");
            Console.WriteLine(JsonConvert.SerializeObject(cards, Formatting.None));

            var skillsMetadata = new Dictionary <string, object>()
            {
                { "cards", cards }
            };

            try {
                await client.MetadataManager.CreateFileMetadataAsync(boxBody.source.id.Value, skillsMetadata, "global", "boxSkillsCards");

                Console.WriteLine("Created metadata");
            } catch (Exception e) {
                Console.WriteLine("Exception creating metadata. Trying update");
                Console.WriteLine(e);
                BoxMetadataUpdate updateObj = new BoxMetadataUpdate
                {
                    Op    = MetadataUpdateOp.replace,
                    Path  = "/cards",
                    Value = cards
                };
                try
                {
                    await client.MetadataManager.UpdateFileMetadataAsync(boxBody.source.id.Value, new List <BoxMetadataUpdate>() { updateObj }, "global", "boxSkillsCards");
                } catch (Exception e2) {
                    Console.WriteLine("Exception updating metadata. giving up");
                    Console.WriteLine(e2);
                    return;
                }
                Console.WriteLine("Successfully updated metadata");
            }
        }
コード例 #26
0
        static async Task MainAsync()
        {
            // rename the private_key.pem.example to private_key.pem and put your JWT private key in the file
            var privateKey = File.ReadAllText("private_key.pem");

            var boxConfig = new BoxConfig(CLIENT_ID, CLIENT_SECRET, ENTERPRISE_ID, privateKey, JWT_PRIVATE_KEY_PASSWORD, JWT_PUBLIC_KEY_ID);

            // Proxy configuration - set isProxyEnabled = true if using Fiddler!!
            if (isProxyEnabled != false)
            {
                System.Net.WebProxy webProxy   = new System.Net.WebProxy("http://127.0.0.1:8888");
                NetworkCredential   credential = new NetworkCredential("testUser", "testPass");
                webProxy.Credentials = credential;
                boxConfig.WebProxy   = webProxy;
            }

            var boxJWT = new BoxJWTAuth(boxConfig);

            var adminToken = boxJWT.AdminToken();

            Console.WriteLine("Admin Token: " + adminToken);
            Console.WriteLine();

            var adminClient = boxJWT.AdminClient(adminToken);

            var adminFunc = new Func(adminClient);

            adminFunc.GetFolderItems();

            var       userId     = "3768478578";
            var       userToken  = boxJWT.UserToken(userId); // valid for 60 minutes so should be cached and re-used
            BoxClient userClient = boxJWT.UserClient(userToken, userId);

            var userFunc = new Func(userClient);

            userFunc.GetFolderItems();

            // Stream fileContents = await userClient.FilesManager.DownloadStreamAsync(id: "675996854920"); // Download the file 675996854920

            // var userRequest = new BoxUserRequest() { Name = "test appuser", IsPlatformAccessOnly = true };
            // var appUser = await adminClient.UsersManager.CreateEnterpriseUserAsync(userRequest);
            // Console.WriteLine("Created App User");

            // var userToken = boxJWT.UserToken(appUser.Id);
            // var userClient = boxJWT.UserClient(userToken, appUser.Id);

            // var userDetails = await userClient.UsersManager.GetCurrentUserInformationAsync();
            // Console.WriteLine("\nApp User Details:");
            // Console.WriteLine("\tId: {0}", userDetails.Id);
            // Console.WriteLine("\tName: {0}", userDetails.Name);
            // Console.WriteLine("\tStatus: {0}", userDetails.Status);
            // Console.WriteLine();

            // await adminClient.UsersManager.DeleteEnterpriseUserAsync(appUser.Id, false, true);
            // Console.WriteLine("Deleted App User");
        }
コード例 #27
0
        public static async Task GetInfo()
        {
            var config  = new BoxConfig(BoxLogin.sBoxClientId, BoxLogin.sBoxClientSecret, new Uri("http://localhost"));
            var session = new OAuthSession(BoxLogin.token, "NOT_NEEDED", 3600, "bearer");

            client = new BoxClient(config, session);
            BoxUser currentUser = await client.UsersManager.GetCurrentUserInformationAsync();

            UserName = currentUser.Name;
        }
コード例 #28
0
        public async Task GetFolder_LiveSession_ValidResponse_DeflateCompression()
        {
            var boxConfig = new BoxConfig(ClientId, ClientSecret, RedirectUri)
            {
                AcceptEncoding = CompressionType.deflate
            };
            var boxClient = new BoxClient(boxConfig, _auth);

            await AssertFolderContents(boxClient);
        }
コード例 #29
0
        public static async Task CompleteAuthorization(UserTokenHandler tokenHandler, string authCode)
        {
            var config = new BoxConfig(ClientID, ClientSecret, new Uri(RedirectUri));
            var client = new BoxClient(config);

            client.Auth.SessionAuthenticated += tokenHandler.SessionAuthenticated;
            client.Auth.SessionInvalidated   += tokenHandler.SessionInvalidated;

            await client.Auth.AuthenticateAsync(authCode).ConfigureAwait(false);
        }
コード例 #30
0
ファイル: Thresh.cs プロジェクト: geramz/PortAIO
        private static void LoadMenu()
        {
            Config = MainMenu.AddMenu("Thresh", "thresh_menu");

            SpellConfig = Config.AddSubMenu("Spell Settings", "SpellSettings");
            SpellConfig.Add("autoQ", new CheckBox("Auto Q Dash Enemy", true));
            SpellConfig.Add("dontQ2", new CheckBox("Don't Auto Q2", true));
            SpellConfig.Add("dQ2if", new Slider("Don't Q2 if Enemies > allies", 1, 0, 5));
            SpellConfig.Add("farmE", new CheckBox("Farm with E", true));
            SpellConfig.AddLabel("Q BlackList :");
            foreach (var hero in HeroManager.Enemies)
            {
                SpellConfig.Add("QList" + hero.NetworkId, new CheckBox("BlackList: " + hero.ChampionName, false));
            }

            SpellConfig.Add("FlayPush", new KeyBind("Flay Push Key", false, KeyBind.BindTypes.HoldActive, 'T'));
            SpellConfig.Add("FlayPull", new KeyBind("Flay Pull Key", false, KeyBind.BindTypes.HoldActive, 'H'));

            FleeConfig = Config.AddSubMenu("Flee Settings", "FleeSettings");
            FleeConfig.Add("flee", new KeyBind("Flee", false, KeyBind.BindTypes.HoldActive, 'Z'));
            FleeConfig.Add("autoEpush", new CheckBox("Auto E push", true));

            PredictConfig = Config.AddSubMenu("Predict Settings", "PredictSettings");
            PredictConfig.Add("PredictionMode", new ComboBox("Prediction Mode", 0, "Common", "OKTW", "SDK", "SPrediction"));
            PredictConfig.Add("HitChance", new ComboBox("Hit Chance", 0, "Very High", "High", "Medium"));

            BoxConfig = Config.AddSubMenu("Box Settings", "BoxSettings");
            BoxConfig.Add("BoxCount", new Slider("Box Count", 2, 1, 6));
            BoxConfig.Add("BoxMode", new ComboBox("Box Mode", 0, "Prediction", "Now"));

            SupportConfig = Config.AddSubMenu("Support Mode", "SupportMode");
            SupportConfig.Add("SupportMode", new CheckBox("Suppor tMode", true));
            SupportConfig.Add("SupportModeRange", new Slider("Support Mode Range", (int)Player.AttackRange + 200, (int)Player.AttackRange, 2000));
            SupportConfig.Add("AttackADC", new CheckBox("Attack ADC's Target [TEST]", true));


            DrawConfig = Config.AddSubMenu("Drawing Settings", "DrawingSettings");
            DrawConfig.Add("Drawwhenskillisready", new CheckBox("Draw when skill is ready", true));
            DrawConfig.Add("drawQ", new CheckBox("Draw Q Range", true));
            DrawConfig.Add("drawW", new CheckBox("Draw W Range", true));
            DrawConfig.Add("drawE", new CheckBox("Draw E Range", true));
            DrawConfig.Add("drawR", new CheckBox("Draw R Range", true));
            DrawConfig.Add("drawtg", new CheckBox("Draw Target", true));

            SmartKeyConfig = Config.AddSubMenu("Smart Cast", "SmartCast");
            SmartKeyConfig.Add("EnableFollow", new CheckBox("Enable Follow Options,Prss Q/W/E Auto Cast Spell", true));
            SmartKeyConfig.Add("SmartCastQ", new CheckBox("Smart Cast Q", true));
            SmartKeyConfig.Add("SmartCastW", new CheckBox("Smart Cast W", true));
            SmartKeyConfig.Add("SmartCastE", new CheckBox("Smart Cast E", true));

            TowerConfig = Config.AddSubMenu("Turret Settings", "TurretSettings");
            TowerConfig.Add("QEallyTurrettarget", new CheckBox("Q/E ally Turret’s target", true));
            TowerConfig.Add("QEtargetintoallyturret", new CheckBox("Q/E target into ally turret", true));
            TowerConfig.Add("DontQ2inenemyturret", new CheckBox("Don't Q2 in enemy turret", true));
        }