mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-20 14:15:12 +00:00
When we delete an authorization, we often need to use basic authentication because the client might not have the associated token stored anymore. If 2fa is enabled, the client needs to be able to pass that along.
167 lines
8.9 KiB
C#
167 lines
8.9 KiB
C#
using System;
|
||
using System.Diagnostics.CodeAnalysis;
|
||
using System.Reactive;
|
||
|
||
namespace Octokit.Reactive
|
||
{
|
||
public interface IObservableAuthorizationsClient
|
||
{
|
||
/// <summary>
|
||
/// Get all <see cref="Authorization"/>s for the authenticated user. This method requires basic auth.
|
||
/// </summary>
|
||
/// <remarks>
|
||
/// See <a href="http://developer.github.com/v3/oauth/#list-your-authorizations">API documentation</a> for more
|
||
/// details.
|
||
/// </remarks>
|
||
/// <returns>An <see cref="Authorization"/></returns>
|
||
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
|
||
Justification = "It's an API call, so it's not a property.")]
|
||
IObservable<Authorization> GetAll();
|
||
|
||
/// <summary>
|
||
/// Get a specific <see cref="Authorization"/> for the authenticated user. This method requires basic auth.
|
||
/// </summary>
|
||
/// <remarks>
|
||
/// See <a href="http://developer.github.com/v3/oauth/#get-a-single-authorization">API documentation</a> for
|
||
/// more details.
|
||
/// </remarks>
|
||
/// <param name="id">The id of the <see cref="Authorization"/></param>
|
||
/// <returns>An <see cref="Authorization"/></returns>
|
||
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get",
|
||
Justification = "It's fiiiine. It's fine. Trust us.")]
|
||
IObservable<Authorization> Get(int id);
|
||
|
||
/// <summary>
|
||
/// This method will create a new authorization for the specified OAuth application, only if an authorization
|
||
/// for that application doesn’t already exist for the user. It returns the user’s token for the application
|
||
/// if one exists. Otherwise, it creates one.
|
||
/// </summary>
|
||
/// <remarks>
|
||
/// See <a href="http://developer.github.com/v3/oauth/#get-or-create-an-authorization-for-a-specific-app">API
|
||
/// documentation</a> for more details.
|
||
/// </remarks>
|
||
/// <param name="clientId">Client ID for the OAuth application that is requesting the token</param>
|
||
/// <param name="clientSecret">The client secret</param>
|
||
/// <param name="newAuthorization">Defines the scopes and metadata for the token</param>
|
||
/// <exception cref="AuthorizationException">Thrown when the user does not have permission to make
|
||
/// this request. Check </exception>
|
||
/// <exception cref="TwoFactorRequiredException">Thrown when the current account has two-factor
|
||
/// authentication enabled.</exception>
|
||
/// <returns></returns>
|
||
IObservable<ApplicationAuthorization> GetOrCreateApplicationAuthentication(
|
||
string clientId,
|
||
string clientSecret,
|
||
NewAuthorization newAuthorization);
|
||
|
||
/// <summary>
|
||
/// This method will create a new authorization for the specified OAuth application, only if an authorization
|
||
/// for that application doesn’t already exist for the user. It returns the user’s token for the application
|
||
/// if one exists. Otherwise, it creates one.
|
||
/// </summary>
|
||
/// <remarks>
|
||
/// See <a href="http://developer.github.com/v3/oauth/#get-or-create-an-authorization-for-a-specific-app">API
|
||
/// documentation</a> for more details.
|
||
/// </remarks>
|
||
/// <param name="clientId">Client ID for the OAuth application that is requesting the token</param>
|
||
/// <param name="clientSecret">The client secret</param>
|
||
/// <param name="newAuthorization">Defines the scopes and metadata for the token</param>
|
||
/// <param name="twoFactorAuthenticationCode">The two-factor authentication code provided by the user</param>
|
||
/// <exception cref="AuthorizationException">Thrown when the user does not have permission to make
|
||
/// this request. Check </exception>
|
||
/// <exception cref="TwoFactorChallengeFailedException">Thrown when the two-factor code is not
|
||
/// valid.</exception>
|
||
/// <returns></returns>
|
||
IObservable<ApplicationAuthorization> GetOrCreateApplicationAuthentication(
|
||
string clientId,
|
||
string clientSecret,
|
||
NewAuthorization newAuthorization,
|
||
string twoFactorAuthenticationCode);
|
||
|
||
/// <summary>
|
||
/// Checks the validity of an OAuth token without running afoul of normal rate limits for failed login attempts.
|
||
/// </summary>
|
||
/// <remarks>
|
||
/// This method requires authentication.
|
||
/// See the <a href="https://developer.github.com/v3/oauth_authorizations/#check-an-authorization">API documentation</a> for more information.
|
||
/// </remarks>
|
||
/// <param name="clientId">Client ID of the OAuth application for the token</param>
|
||
/// <param name="accessToken">The OAuth token to check</param>
|
||
/// <returns>The valid <see cref="ApplicationAuthorization"/>.</returns>
|
||
IObservable<ApplicationAuthorization> CheckApplicationAuthentication(string clientId, string accessToken);
|
||
|
||
/// <summary>
|
||
/// Resets a valid OAuth token for an OAuth application without end user involvment.
|
||
/// </summary>
|
||
/// <remarks>
|
||
/// This method requires authentication.
|
||
/// See the <a href="https://developer.github.com/v3/oauth_authorizations/#reset-an-authorization">API documentation</a> for more information.
|
||
/// </remarks>
|
||
/// <param name="clientId">ClientID of the OAuth application for the token</param>
|
||
/// <param name="accessToken">The OAuth token to reset</param>
|
||
/// <returns>The valid <see cref="ApplicationAuthorization"/> with a new OAuth token</returns>
|
||
IObservable<ApplicationAuthorization> ResetApplicationAuthentication(string clientId, string accessToken);
|
||
|
||
/// <summary>
|
||
/// Revokes a single OAuth token for an OAuth application.
|
||
/// </summary>
|
||
/// <remarks>
|
||
/// This method requires authentication.
|
||
/// See the <a href="https://developer.github.com/v3/oauth_authorizations/#revoke-an-authorization-for-an-application">API documentation for more information.</a>
|
||
/// </remarks>
|
||
/// <param name="clientId">ClientID of the OAuth application for the token</param>
|
||
/// <param name="accessToken">The OAuth token to revoke</param>
|
||
/// <returns></returns>
|
||
IObservable<Unit> RevokeApplicationAuthentication(string clientId, string accessToken);
|
||
|
||
/// <summary>
|
||
/// Revokes every OAuth token for an OAuth application.
|
||
/// </summary>
|
||
/// <remarks>
|
||
/// This method requires authentication.
|
||
/// See the <a href="https://developer.github.com/v3/oauth_authorizations/#revoke-all-authorizations-for-an-application">API documentation for more information.</a>
|
||
/// </remarks>
|
||
/// <param name="clientId">ClientID of the OAuth application for the token</param>
|
||
/// <returns></returns>
|
||
IObservable<Unit> RevokeAllApplicationAuthentications(string clientId);
|
||
|
||
/// <summary>
|
||
/// Update the <see cref="Authorization"/> specified by the id.
|
||
/// </summary>
|
||
/// <param name="id">The id of the <see cref="Authorization"/></param>
|
||
/// <param name="authorizationUpdate">The changes to make to the authorization</param>
|
||
/// <returns></returns>
|
||
IObservable<Authorization> Update(int id, AuthorizationUpdate authorizationUpdate);
|
||
|
||
/// <summary>
|
||
/// Deletes the specified <see cref="Authorization"/>.
|
||
/// </summary>
|
||
/// <remarks>
|
||
/// This method requires authentication.
|
||
/// See the <a href="http://developer.github.com/v3/oauth/#delete-an-authorization">API
|
||
/// documentation</a> for more details.
|
||
/// </remarks>
|
||
/// <param name="id">The system-wide ID of the authorization to delete</param>
|
||
/// <exception cref="AuthorizationException">
|
||
/// Thrown when the current user does not have permission to make the request.
|
||
/// </exception>
|
||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||
IObservable<Unit> Delete(int id);
|
||
|
||
/// <summary>
|
||
/// Deletes the specified <see cref="Authorization"/>.
|
||
/// </summary>
|
||
/// <remarks>
|
||
/// This method requires authentication.
|
||
/// See the <a href="http://developer.github.com/v3/oauth/#delete-an-authorization">API
|
||
/// documentation</a> for more details.
|
||
/// </remarks>
|
||
/// <param name="id">The system-wide ID of the authorization to delete</param>
|
||
/// <param name="twoFactorAuthenticationCode">Two factor authorization code</param>
|
||
/// <exception cref="AuthorizationException">
|
||
/// Thrown when the current user does not have permission to make the request.
|
||
/// </exception>
|
||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||
IObservable<Unit> Delete(int id, string twoFactorAuthenticationCode);
|
||
}
|
||
}
|