Example #1
0
		public GitHub(HttpClient httpClient, IGitHubApiCredentials githubApiCredentials)
			: this(httpClient)
		{
			if (githubApiCredentials == null)
			{
				throw new ArgumentNullException("gitHubApiSettings", "The Github settings provider cannot be null.");
			}

			this.UpdateCrentials(githubApiCredentials);
		}
Example #2
0
		public void UpdateCrentials(IGitHubApiCredentials githubApiCredentials)
		{
			if (!string.IsNullOrEmpty(githubApiCredentials.Token))
			{
				this.httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", githubApiCredentials.Token);
			}
			else if (!string.IsNullOrEmpty(githubApiCredentials.Username))
			{
				string usernamePasswordToken = Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format(CultureInfo.InvariantCulture,
					"{0}:{1}", new object[] { githubApiCredentials.Username, githubApiCredentials.Password })));
				this.httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", usernamePasswordToken);
			}
		}
Example #3
0
		public GitHub(IGitHubApiCredentials githubApiCredentials)
			: this(new HttpClient(), githubApiCredentials)
		{

		}