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

The "v" parameter with version number becomes obligatory for all API … #228

Merged
merged 1 commit into from
Mar 7, 2018
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public VKontakteAuthenticatedContext(IOwinContext context, JObject user, string
User = user;
AccessToken = accessToken;

Id = TryGetValue(user, "uid");
Id = TryGetValue(user, "id");
var firstName = TryGetValue(user, "first_name");
var lastName = TryGetValue(user, "last_name");
UserName = firstName + " " + lastName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected override Task ApplyResponseChallengeAsync()
var state = Options.StateDataFormat.Protect(properties);

var authorizationEndpoint =
$"{Options.Endpoints.AuthorizationEndpoint}?client_id={Uri.EscapeDataString(Options.ClientId)}&redirect_uri={Uri.EscapeDataString(redirectUri)}&scope={Uri.EscapeDataString(scope)}&state={Uri.EscapeDataString(state)}&display={Uri.EscapeDataString(Options.Display)}";
$"{Options.Endpoints.AuthorizationEndpoint}?client_id={Uri.EscapeDataString(Options.ClientId)}&redirect_uri={Uri.EscapeDataString(redirectUri)}&scope={Uri.EscapeDataString(scope)}&state={Uri.EscapeDataString(state)}&display={Uri.EscapeDataString(Options.Display)}&v={Uri.EscapeDataString(Options.ApiVersion)}";

Response.Redirect(authorizationEndpoint);

Expand Down Expand Up @@ -156,7 +156,7 @@ private async Task<JObject> GetUser(JObject response, string accessToken)

// Get the VK user
var userRequestUri = new Uri(
$"{Options.Endpoints.UserInfoEndpoint}?access_token={Uri.EscapeDataString(accessToken)}&user_id{userId}");
$"{Options.Endpoints.UserInfoEndpoint}?access_token={Uri.EscapeDataString(accessToken)}&user_id{userId}&v={Uri.EscapeDataString(Options.ApiVersion)}");
var userResponse = await _httpClient.GetAsync(userRequestUri, Request.CallCancelled);
userResponse.EnsureSuccessStatusCode();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class VKontakteAuthenticationOptions : AuthenticationOptions
private const string UserInfoEndpoint = "https://api.vk.com/method/users.get";
private const string DefaultCallbackPath = "/signin-vkontakte";
private const string DefaultDisplayMode = "page";
private const string DefaultApiVersion = "5.73";

/// <summary>
/// Gets or sets the a pinned certificate validator to use to validate the endpoints used
Expand Down Expand Up @@ -100,10 +101,18 @@ public string Caption
/// </summary>
public ISecureDataFormat<AuthenticationProperties> StateDataFormat { get; set; }

/// <summary>
/// Initializes a new <see cref="VKontakteAuthenticationOptions" />
/// </summary>
public VKontakteAuthenticationOptions()
/// <summary>
/// Default API version. Required.
/// </summary>
/// <remarks>
/// Defaults to 5.73
/// </remarks>
public string ApiVersion { get; set; }

/// <summary>
/// Initializes a new <see cref="VKontakteAuthenticationOptions" />
/// </summary>
public VKontakteAuthenticationOptions()
: base(Constants.DefaultAuthenticationType)
{
Caption = Constants.DefaultAuthenticationType;
Expand All @@ -118,6 +127,7 @@ public VKontakteAuthenticationOptions()
TokenEndpoint = TokenEndpoint,
UserInfoEndpoint = UserInfoEndpoint
};
ApiVersion = DefaultApiVersion;
}
}
}