Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds missing OAuth login request parameters #1919

Merged
merged 1 commit into from
Jan 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Octokit.Tests/Clients/OauthClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ public void ReturnsUrlWithAllParameters()
var request = new OauthLoginRequest("secret")
{
RedirectUri = new Uri("https://example.com/foo?foo=bar"),
Login = "johnDOE",
Scopes = { "foo", "bar" },
State = "canARY"
State = "canARY",
AllowSignup = false
};
var connection = Substitute.For<IConnection>();
connection.BaseAddress.Returns(new Uri("https://api.github.com"));
Expand All @@ -54,7 +56,7 @@ public void ReturnsUrlWithAllParameters()
var result = client.GetGitHubLoginUrl(request);

Assert.Equal("/login/oauth/authorize", result.AbsolutePath);
Assert.Equal("?client_id=secret&redirect_uri=https%3A%2F%2Fexample.com%2Ffoo%3Ffoo%3Dbar&scope=foo%2Cbar&state=canARY", result.Query);
Assert.Equal("?client_id=secret&redirect_uri=https%3A%2F%2Fexample.com%2Ffoo%3Ffoo%3Dbar&login=johnDOE&scope=foo%2Cbar&state=canARY&allow_signup=false", result.Query);
}
}

Expand Down
13 changes: 13 additions & 0 deletions Octokit/Models/Request/OauthLoginRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ public OauthLoginRequest(string clientId)
[Parameter(Key = "redirect_uri")]
public Uri RedirectUri { get; set; }

/// <summary>
/// Suggests a specific account to use for signing in and authorizing the app.
/// </summary>
[Parameter(Key = "login")]
public string Login { get; set; }

/// <summary>
/// A set of scopes to request. If not provided, scope defaults to an empty list of scopes for users that don’t
/// have a valid token for the app. For users who do already have a valid token for the app, the user won’t be
Expand All @@ -60,6 +66,13 @@ public OauthLoginRequest(string clientId)
[Parameter(Key = "state")]
public string State { get; set; }

/// <summary>
/// Whether or not unauthenticated users will be offered an option to sign up for GitHub during the OAuth flow.
/// The default is <c>true</c>. Use <c>false</c> in the case that a policy prohibits signups.
/// </summary>
[Parameter(Key = "allow_signup")]
public bool? AllowSignup { get; set; }

internal string DebuggerDisplay
{
get
Expand Down