Implemented methods for creating an authorization without having to specify an app clientid/clientsecret.

These methods will ONLY work with username/password Basic Auth.

Added a helper method to return a GitHub client using basic auth credentials as if you have both password and oauth token environment variables, you get credentials based on the oauth token.
This commit is contained in:
Henrik Andersson
2015-12-11 00:16:36 +10:00
parent 2c2ba0ce6d
commit 2152ba4d14
6 changed files with 254 additions and 0 deletions
+37
View File
@@ -47,6 +47,43 @@ namespace Octokit
Justification = "It's fiiiine. It's fine. Trust us.")]
Task<Authorization> Get(int id);
/// <summary>
/// Creates a new personal token for the authenticated user.
/// </summary>
/// <remarks>
/// This method requires authentication.
/// See the <a href="https://developer.github.com/v3/oauth_authorizations/#create-a-new-authorization">API documentation</a> for more information.
/// </remarks>
/// <param name="newAuthorization">Describes the new authorization to create</param>
/// <exception cref="AuthorizationException">
/// Thrown when the current user does not have permission to make this request.
/// </exception>
/// <exception cref="TwoFactorRequiredException">
/// Thrown when the current account has two-factor authentication enabled and an authentication code is required.
/// </exception>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>The created <see cref="Authorization"/>.</returns>
Task<ApplicationAuthorization> Create(NewAuthorization newAuthorization);
/// <summary>
/// Creates a new personal token for the authenticated user.
/// </summary>
/// <remarks>
/// This method requires authentication.
/// See the <a href="https://developer.github.com/v3/oauth_authorizations/#create-a-new-authorization">API documentation</a> for more information.
/// </remarks>
/// <param name="twoFactorAuthenticationCode">The two-factor authentication code in response to the current user's previous challenge</param>
/// <param name="newAuthorization">Describes the new authorization to create</param>
/// <exception cref="AuthorizationException">
/// Thrown when the current user does not have permission to make this request.
/// </exception>
/// <exception cref="TwoFactorRequiredException">
/// Thrown when the current account has two-factor authentication enabled and an authentication code is required.
/// </exception>
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
/// <returns>The created <see cref="Authorization"/>.</returns>
Task<ApplicationAuthorization> Create(NewAuthorization newAuthorization, string twoFactorAuthenticationCode);
/// <summary>
/// Creates a new authorization for the specified OAuth application if an authorization for that application
/// doesnt already exist for the user; otherwise, it fails.