diff --git a/Octokit.Reactive/Clients/IObservableOauthClient.cs b/Octokit.Reactive/Clients/IObservableOauthClient.cs new file mode 100644 index 00000000..01f1d6f1 --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableOauthClient.cs @@ -0,0 +1,28 @@ +using System; + +namespace Octokit.Reactive +{ + public interface IObservableOauthClient + { + /// + /// Gets the URL used in the first step of the web flow. The Web application should redirect to this URL. + /// + /// Parameters to the Oauth web flow login url + /// + IObservable GetGitHubLoginUrl(OauthLoginRequest request); + + /// + /// Makes a request to get an access token using the code returned when GitHub.com redirects back from the URL + /// GitHub login url to the application. + /// + /// + /// 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. + /// + /// + /// + IObservable CreateAccessToken(OauthTokenRequest request); + } +} diff --git a/Octokit.Reactive/Clients/ObservableOauthClient.cs b/Octokit.Reactive/Clients/ObservableOauthClient.cs new file mode 100644 index 00000000..cd73a94f --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableOauthClient.cs @@ -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 GetGitHubLoginUrl(OauthLoginRequest request) + { + return Observable.Return(_client.Oauth.GetGitHubLoginUrl(request)); + } + + public IObservable CreateAccessToken(OauthTokenRequest request) + { + return _client.Oauth.CreateAccessToken(request).ToObservable(); + } + } +} diff --git a/Octokit.Reactive/IObservableGitHubClient.cs b/Octokit.Reactive/IObservableGitHubClient.cs index ecc8dd89..c8983ff8 100644 --- a/Octokit.Reactive/IObservableGitHubClient.cs +++ b/Octokit.Reactive/IObservableGitHubClient.cs @@ -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; } diff --git a/Octokit.Reactive/ObservableGitHubClient.cs b/Octokit.Reactive/ObservableGitHubClient.cs index 8b251ecf..cba117f2 100644 --- a/Octokit.Reactive/ObservableGitHubClient.cs +++ b/Octokit.Reactive/ObservableGitHubClient.cs @@ -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; } diff --git a/Octokit.Reactive/Octokit.Reactive.csproj b/Octokit.Reactive/Octokit.Reactive.csproj index 801fbd70..453b88ae 100644 --- a/Octokit.Reactive/Octokit.Reactive.csproj +++ b/Octokit.Reactive/Octokit.Reactive.csproj @@ -73,7 +73,9 @@ Properties\SolutionInfo.cs + + @@ -161,7 +163,6 @@ -