diff --git a/Octokit.Reactive/Clients/IObservableOauthClient.cs b/Octokit.Reactive/Clients/IObservableOauthClient.cs
index 88c7a3547d..5313caa819 100644
--- a/Octokit.Reactive/Clients/IObservableOauthClient.cs
+++ b/Octokit.Reactive/Clients/IObservableOauthClient.cs
@@ -46,5 +46,12 @@ public interface IObservableOauthClient
/// The response you received from
///
IObservable CreateAccessTokenForDeviceFlow(string clientId, OauthDeviceFlowResponse deviceFlowResponse);
+
+ ///
+ /// Makes a request to get an access token using the refresh token returned in .
+ ///
+ /// Token renewal request.
+ /// with the new token set.
+ IObservable CreateAccessTokenFromRenewalToken(OauthTokenRenewalRequest request);
}
}
diff --git a/Octokit.Reactive/Clients/ObservableOauthClient.cs b/Octokit.Reactive/Clients/ObservableOauthClient.cs
index fb51cd5c4d..1e4f42ef66 100644
--- a/Octokit.Reactive/Clients/ObservableOauthClient.cs
+++ b/Octokit.Reactive/Clients/ObservableOauthClient.cs
@@ -3,6 +3,10 @@
namespace Octokit.Reactive
{
+ ///
+ /// Wrapper around for use with
+ ///
+ ///
public class ObservableOauthClient : IObservableOauthClient
{
readonly IGitHubClient _client;
@@ -14,59 +18,30 @@ public ObservableOauthClient(IGitHubClient client)
_client = client;
}
- ///
- /// 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
- ///
public Uri GetGitHubLoginUrl(OauthLoginRequest request)
{
return _client.Oauth.GetGitHubLoginUrl(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.
- ///
- ///
- ///
public IObservable CreateAccessToken(OauthTokenRequest request)
{
return _client.Oauth.CreateAccessToken(request).ToObservable();
}
- ///
- /// Makes a request to initiate the device flow authentication.
- ///
- ///
- /// Returns a user verification code and verification URL that the you will use to prompt the user to authenticate.
- /// This request also returns a device verification code that you must use to receive an access token to check the status of user authentication.
- ///
- ///
- ///
public IObservable InitiateDeviceFlow(OauthDeviceFlowRequest request)
{
return _client.Oauth.InitiateDeviceFlow(request).ToObservable();
}
- ///
- /// Makes a request to get an access token using the response from .
- ///
- ///
- /// Will poll the access token endpoint, until the device and user codes expire or the user has successfully authorized the app with a valid user code.
- ///
- /// The client Id you received from GitHub when you registered the application.
- /// The response you received from
- ///
public IObservable CreateAccessTokenForDeviceFlow(string clientId, OauthDeviceFlowResponse deviceFlowResponse)
{
return _client.Oauth.CreateAccessTokenForDeviceFlow(clientId, deviceFlowResponse).ToObservable();
}
+
+ public IObservable CreateAccessTokenFromRenewalToken(OauthTokenRenewalRequest request)
+ {
+ return _client.Oauth.CreateAccessTokenFromRenewalToken(request)
+ .ToObservable();
+ }
}
}
diff --git a/Octokit.Tests/Clients/OauthClientTests.cs b/Octokit.Tests/Clients/OauthClientTests.cs
index a6f5187024..c0842bb5a5 100644
--- a/Octokit.Tests/Clients/OauthClientTests.cs
+++ b/Octokit.Tests/Clients/OauthClientTests.cs
@@ -1,5 +1,4 @@
using System;
-using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using NSubstitute;
@@ -208,4 +207,75 @@ public async Task DeserializesOAuthScopeFormat()
Assert.Contains("user:email", token.Scope);
}
}
+
+ public class TheCreateAccessTokenFromRenewalTokenMethod
+ {
+ [Fact]
+ public async Task PostsWithCorrectBodyAndContentType()
+ {
+ var responseToken = new OauthToken("bearer", "someaccesstoken", 3000, "refreshtoken", 10000, Array.Empty(), null, null, null);
+ var response = Substitute.For>();
+ response.Body.Returns(responseToken);
+
+ var connection = Substitute.For();
+ connection.BaseAddress.Returns(new Uri("https://api.github.com/"));
+
+ Uri calledUri = null;
+ FormUrlEncodedContent calledBody = null;
+ Uri calledHostAddress = null;
+ connection.Post(
+ Arg.Do(uri => calledUri = uri),
+ Arg.Do