示例#1
0
        public static void Main(string[] arguments)
        {
            //CheckUsage(arguments);

            //string clientId = arguments[0];
            //string clientSecret = arguments[1];

            string clientId = "49e17241-0631-47ec-bbf5-eface6552ea8";
            string clientSecret = "1d4e4d1b-9798-4bd3-bd86-f17ca00505e3";

            Console.WriteLine("Please authorize this application in the browser window that has just opened");
            var authInfo = GetAuthorization(clientId, clientSecret);

            Console.WriteLine("Authorization successful");
            var client = new AppHarborClient(authInfo);

            Console.WriteLine("Applications:");
            foreach (var application in client.GetApplications())
            {
                Console.WriteLine(" - {0}, {1}", application.Name, application.Slug);
                var builds = client.GetBuilds(application.Slug);
                Console.WriteLine("Builds:\n{0}", String.Join(", ", builds.Select(x => new { x.Status, x.Deployed, x.DownloadUrl })));
            }

            var user = client.GetUser();
            Console.WriteLine("User: {0}, Email: {1}", user.Username, String.Join(", ", user.Email_Addresses));
        }
示例#2
0
        public ActionResult Auth(string code)
        {
            AuthInfo authInfo = null;

            authInfo = AppHarborClient.GetAuthInfo(Config.ClientId, Config.ClientSecret, code);

            if (authInfo != null)
            {
                TokenStore.AccessToken = authInfo.AccessToken;
            }

            return(RedirectToAction("Index"));
        }
示例#3
0
        public static void TestInit(TestContext context)
        {
            if (string.IsNullOrWhiteSpace(AccessToken))
            {
                Assert.Inconclusive("Please specify a valid AccessToken");
            }

            // zzzintegration + first 20 chracters of newly created guid
            // this should result in a fairly unique applicationSlug
            ApplicationSlug = "zzzintegration" + Guid.NewGuid()
                              .ToString("N")
                              .ToLower()
                              .Substring(0, 20);

            Api = new AppHarborClient(new AuthInfo(AccessToken));
        }
		public static void TestInit(TestContext context)
		{
			if (string.IsNullOrWhiteSpace(AccessToken))
			{
				Assert.Inconclusive("Please specify a valid AccessToken");
			}

			// zzzintegration + first 20 chracters of newly created guid
			// this should result in a fairly unique applicationid
			ApplicationId = "zzzintegration" + Guid.NewGuid()
				.ToString("N")
				.ToLower()
				.Substring(0, 20);

			Api = new AppHarborClient(new AuthInfo(AccessToken));
		}
示例#5
0
		public static void InitTest(TestContext context)
		{
			var authInfo = new AuthInfo("unittest");

			var client = new RestClient(MockHttp.BaseUrl);
			client.HttpFactory = new SimpleFactory<SampleDataMockHttp>();
			Api = new MockedAppHarborClient(authInfo, client);

			var clientEmptyListData = new RestClient(MockHttp.BaseUrl);
			clientEmptyListData.HttpFactory = new SimpleFactory<EmptyListDataMockHttp>();
			EmptyListDataApi = new MockedAppHarborClient(authInfo, clientEmptyListData);

			var clientExistingData = new RestClient(MockHttp.BaseUrl);
			clientExistingData.HttpFactory = new SimpleFactory<ExistingDataMockHttp>();
			ExistingDataDataApi = new MockedAppHarborClient(authInfo, clientExistingData);

			ApplicationSlug = ":application";
		}
示例#6
0
		public static void Main(string[] arguments)
		{
			CheckUsage(arguments);

			string clientId = arguments[0];
			string clientSecret = arguments[1];

			Console.WriteLine("Please authorize this application in the browser window that has just opened");
			var authInfo = GetAuthorization(clientId, clientSecret);

			Console.WriteLine("Authorization successful");
			var client = new AppHarborClient(authInfo);

			Console.WriteLine("Applications:");
			foreach (var application in client.GetApplications())
			{
				Console.WriteLine(" - {0}", application.Name);
			}
		}
示例#7
0
        public static void Main(string[] arguments)
        {
            CheckUsage(arguments);

            string clientId     = arguments[0];
            string clientSecret = arguments[1];

            Console.WriteLine("Please authorize this application in the browser window that has just opened");
            var authInfo = GetAuthorization(clientId, clientSecret);

            Console.WriteLine("Authorization successful");
            var client = new AppHarborClient(authInfo);

            Console.WriteLine("Applications:");
            foreach (var application in client.GetApplications())
            {
                Console.WriteLine(" - {0}", application.Name);
            }
        }
示例#8
0
 private static AuthInfo GetAuthorization(string clientId, string clientSecret)
 {
     try
     {
         return(AppHarborClient.AskForAuthorization(clientId, clientSecret, TimeSpan.FromMinutes(1)));
     }
     catch (AuthenticationException)
     {
         Console.WriteLine("Failed to get authorization");
         Environment.Exit(-1);
         throw;
     }
     catch (TimeoutException)
     {
         Console.WriteLine("Timeout, you have to be faster than that");
         Environment.Exit(-1);
         throw;
     }
 }
示例#9
0
        public static void InitTest(TestContext context)
        {
            var authInfo = new AuthInfo("unittest");

            var client = new RestSharp.RestClient(MockHttp.BaseUrl);

            client.HttpFactory = new RestSharp.SimpleFactory <SampleDataMockHttp>();
            Api = new MockedAppHarborClient(authInfo, client);

            var clientEmptyListData = new RestSharp.RestClient(MockHttp.BaseUrl);

            clientEmptyListData.HttpFactory = new RestSharp.SimpleFactory <EmptyListDataMockHttp>();
            EmptyListDataApi = new MockedAppHarborClient(authInfo, clientEmptyListData);

            var clientExistingData = new RestSharp.RestClient(MockHttp.BaseUrl);

            clientExistingData.HttpFactory = new RestSharp.SimpleFactory <ExistingDataMockHttp>();
            ExistingDataDataApi            = new MockedAppHarborClient(authInfo, clientExistingData);

            ApplicationID = ":application";
        }
示例#10
0
 public ApiService(string token)
 {
     _AccessToken = token;
     _Api         = new AppHarborClient(new AuthInfo(_AccessToken, "Bearer"));
 }