コード例 #1
0
ファイル: GitHub.cs プロジェクト: Icenium/Github.Api
		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);
		}
コード例 #2
0
ファイル: GitHub.cs プロジェクト: Icenium/Github.Api
		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);
			}
		}
コード例 #3
0
ファイル: GitHub.cs プロジェクト: Icenium/Github.Api
		public GitHub(IGitHubApiCredentials githubApiCredentials)
			: this(new HttpClient(), githubApiCredentials)
		{

		}