mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-19 05:35:11 +00:00
Implement observable oauth client
Rx will never die
This commit is contained in:
28
Octokit.Reactive/Clients/IObservableOauthClient.cs
Normal file
28
Octokit.Reactive/Clients/IObservableOauthClient.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public interface IObservableOauthClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the URL used in the first step of the web flow. The Web application should redirect to this URL.
|
||||
/// </summary>
|
||||
/// <param name="request">Parameters to the Oauth web flow login url</param>
|
||||
/// <returns></returns>
|
||||
IObservable<Uri> GetGitHubLoginUrl(OauthLoginRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Makes a request to get an access token using the code returned when GitHub.com redirects back from the URL
|
||||
/// <see cref="GetGitHubLoginUrl">GitHub login url</see> to the application.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If the user accepts your request, GitHub redirects back to your site with a temporary code in a code
|
||||
/// parameter as well as the state you provided in the previous step in a state parameter. If the states don’t
|
||||
/// match, the request has been created by a third party and the process should be aborted. Exchange this for
|
||||
/// an access token using this method.
|
||||
/// </remarks>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
IObservable<OauthToken> CreateAccessToken(OauthTokenRequest request);
|
||||
}
|
||||
}
|
||||
28
Octokit.Reactive/Clients/ObservableOauthClient.cs
Normal file
28
Octokit.Reactive/Clients/ObservableOauthClient.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Reactive.Linq;
|
||||
using System.Reactive.Threading.Tasks;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
public class ObservableOauthClient : IObservableOauthClient
|
||||
{
|
||||
readonly IGitHubClient _client;
|
||||
|
||||
public ObservableOauthClient(IGitHubClient client)
|
||||
{
|
||||
Ensure.ArgumentNotNull(client, "client");
|
||||
|
||||
_client = client;
|
||||
}
|
||||
|
||||
public IObservable<Uri> GetGitHubLoginUrl(OauthLoginRequest request)
|
||||
{
|
||||
return Observable.Return(_client.Oauth.GetGitHubLoginUrl(request));
|
||||
}
|
||||
|
||||
public IObservable<OauthToken> CreateAccessToken(OauthTokenRequest request)
|
||||
{
|
||||
return _client.Oauth.CreateAccessToken(request).ToObservable();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
IObservableActivitiesClient Activity { get; }
|
||||
IObservableIssuesClient Issue { get; }
|
||||
IObservableMiscellaneousClient Miscellaneous { get; }
|
||||
IObservableOauthClient Oauth { get; }
|
||||
IObservableOrganizationsClient Organization { get; }
|
||||
IObservableRepositoriesClient Repository { get; }
|
||||
IObservableGistsClient Gist { get; }
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Net.Http.Headers;
|
||||
|
||||
namespace Octokit.Reactive
|
||||
{
|
||||
@@ -37,6 +36,7 @@ namespace Octokit.Reactive
|
||||
Issue = new ObservableIssuesClient(gitHubClient);
|
||||
Miscellaneous = new ObservableMiscellaneousClient(gitHubClient.Miscellaneous);
|
||||
Notification = new ObservableNotificationsClient(gitHubClient);
|
||||
Oauth = new ObservableOauthClient(gitHubClient);
|
||||
Organization = new ObservableOrganizationsClient(gitHubClient);
|
||||
Repository = new ObservableRepositoriesClient(gitHubClient);
|
||||
SshKey = new ObservableSshKeysClient(gitHubClient);
|
||||
@@ -56,6 +56,7 @@ namespace Octokit.Reactive
|
||||
public IObservableActivitiesClient Activity { get; private set; }
|
||||
public IObservableIssuesClient Issue { get; private set; }
|
||||
public IObservableMiscellaneousClient Miscellaneous { get; private set; }
|
||||
public IObservableOauthClient Oauth { get; private set; }
|
||||
public IObservableOrganizationsClient Organization { get; private set; }
|
||||
public IObservableRepositoriesClient Repository { get; private set; }
|
||||
public IObservableGistsClient Gist { get; private set; }
|
||||
|
||||
@@ -73,7 +73,9 @@
|
||||
<Compile Include="..\SolutionInfo.cs">
|
||||
<Link>Properties\SolutionInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Clients\IObservableOauthClient.cs" />
|
||||
<Compile Include="Clients\IObservableRepositoryCommitsClients.cs" />
|
||||
<Compile Include="Clients\ObservableOauthClient.cs" />
|
||||
<Compile Include="Clients\ObservableRepositoryCommentsClient.cs" />
|
||||
<Compile Include="Clients\IObservableRepositoryCommentsClient.cs" />
|
||||
<Compile Include="Clients\IObservableDeploymentsClient.cs" />
|
||||
@@ -161,7 +163,6 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="DocPlagiarizer.README.md" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user