예제 #1
0
        public void CanGetAccessToken()
        {
            ////var service = new WeiboService(_consumerKey, _consumerSecret);
            var service = new WeiboService(_iphoneConsumerKey, _iphoneConsumerSecret);
            var redirectUri = service.GetRedirectUri("https://api.weibo.com/oauth2/default.html");  //http://www.google.com.hk/
            Assert.NotNull(redirectUri);
            Process.Start(redirectUri.ToString());
            string code = "7f4b0a4ddb364215a4e614732f9e8439";
            var accessToken = service.GetAccessToken(code, GrantType.AuthorizationCode);
            Assert.NotNull(accessToken);
            Assert.IsNotNullOrEmpty(accessToken.Token);

            var fileMap = new ExeConfigurationFileMap {ExeConfigFilename = @"app.config"};
            // relative path names possible

            // Open another config file
            Configuration config =
               ConfigurationManager.OpenMappedExeConfiguration(fileMap,
               ConfigurationUserLevel.None);

            //read/write from it as usual
            ConfigurationSection mySection = config.GetSection("appSettings");
            ////mySection.
            ////    config.SectionGroups.Clear(); // make changes to it

            config.Save(ConfigurationSaveMode.Full);  // Save changes
        }
예제 #2
0
        public void CanGetAccessToken()
        {
            ////var service = new WeiboService(_consumerKey, _consumerSecret);
            var service     = new WeiboService(_iphoneConsumerKey, _iphoneConsumerSecret);
            var redirectUri = service.GetRedirectUri("https://api.weibo.com/oauth2/default.html");  //http://www.google.com.hk/

            Assert.NotNull(redirectUri);
            Process.Start(redirectUri.ToString());
            string code        = "7f4b0a4ddb364215a4e614732f9e8439";
            var    accessToken = service.GetAccessToken(code, GrantType.AuthorizationCode);

            Assert.NotNull(accessToken);
            Assert.IsNotNullOrEmpty(accessToken.Token);

            var fileMap = new ExeConfigurationFileMap {
                ExeConfigFilename = @"app.config"
            };
            // relative path names possible

            // Open another config file
            Configuration config =
                ConfigurationManager.OpenMappedExeConfiguration(fileMap,
                                                                ConfigurationUserLevel.None);

            //read/write from it as usual
            ConfigurationSection mySection = config.GetSection("appSettings");

            ////mySection.
            ////    config.SectionGroups.Clear(); // make changes to it

            config.Save(ConfigurationSaveMode.Full);  // Save changes
        }
예제 #3
0
        public void CanGetRedirectUri()
        {
            var service     = new WeiboService(_consumerKey, _consumerSecret);
            var redirectUri = service.GetRedirectUri("http://www.google.com.hk/");

            Assert.NotNull(redirectUri);
            Process.Start(redirectUri.ToString());
        }
예제 #4
0
        public void CanGetAuthorizationCode()
        {
            var service     = new WeiboService(_consumerKey, _consumerSecret);
            var redirectUri = service.GetRedirectUri("http://www.google.com.hk/");

            Assert.NotNull(redirectUri);
            Process.Start(redirectUri.ToString());
            string code = "157e795b052e1605a0456040ee9529e2";
        }
예제 #5
0
 public void CanGetRedirectUri()
 {
     var service = new WeiboService(_consumerKey, _consumerSecret);
     var redirectUri = service.GetRedirectUri("http://www.google.com.hk/");
     Assert.NotNull(redirectUri);
     Process.Start(redirectUri.ToString());
 }
예제 #6
0
 public void CanGetAuthorizationCode()
 {
     var service = new WeiboService(_consumerKey, _consumerSecret);
     var redirectUri = service.GetRedirectUri("http://www.google.com.hk/");
     Assert.NotNull(redirectUri);
     Process.Start(redirectUri.ToString());
     string code = "157e795b052e1605a0456040ee9529e2";
 }