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

Upgrade Facebook Graph API version to v22.0 #59387

Merged
merged 2 commits into from
Feb 26, 2025
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 @@ -24,15 +24,15 @@ public static class FacebookDefaults
/// <remarks>
/// For more details about this endpoint, see <see href="https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow#login"/>.
/// </remarks>
public static readonly string AuthorizationEndpoint = "https://www.facebook.com/v14.0/dialog/oauth";
public static readonly string AuthorizationEndpoint = "https://www.facebook.com/v22.0/dialog/oauth";

/// <summary>
/// The OAuth endpoint used to retrieve access tokens.
/// </summary>
public static readonly string TokenEndpoint = "https://graph.facebook.com/v14.0/oauth/access_token";
public static readonly string TokenEndpoint = "https://graph.facebook.com/v22.0/oauth/access_token";

/// <summary>
/// The Facebook Graph API endpoint that is used to gather additional user information.
/// </summary>
public static readonly string UserInformationEndpoint = "https://graph.facebook.com/v14.0/me";
public static readonly string UserInformationEndpoint = "https://graph.facebook.com/v22.0/me";
}
12 changes: 6 additions & 6 deletions src/Security/Authentication/test/FacebookTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public async Task NestedMapWillNotAffectRedirect()
var transaction = await server.SendAsync("http://example.com/base/login");
Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode);
var location = transaction.Response.Headers.Location.AbsoluteUri;
Assert.Contains("https://www.facebook.com/v14.0/dialog/oauth", location);
Assert.Contains("https://www.facebook.com/v22.0/dialog/oauth", location);
Assert.Contains("response_type=code", location);
Assert.Contains("client_id=", location);
Assert.Contains("redirect_uri=" + UrlEncoder.Default.Encode("http://example.com/base/signin-facebook"), location);
Expand Down Expand Up @@ -263,7 +263,7 @@ public async Task MapWillNotAffectRedirect()
var transaction = await server.SendAsync("http://example.com/login");
Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode);
var location = transaction.Response.Headers.Location.AbsoluteUri;
Assert.Contains("https://www.facebook.com/v14.0/dialog/oauth", location);
Assert.Contains("https://www.facebook.com/v22.0/dialog/oauth", location);
Assert.Contains("response_type=code", location);
Assert.Contains("client_id=", location);
Assert.Contains("redirect_uri=" + UrlEncoder.Default.Encode("http://example.com/signin-facebook"), location);
Expand Down Expand Up @@ -298,7 +298,7 @@ public async Task ChallengeWillTriggerRedirection()
var transaction = await server.SendAsync("http://example.com/challenge");
Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode);
var location = transaction.Response.Headers.Location.AbsoluteUri;
Assert.Contains("https://www.facebook.com/v14.0/dialog/oauth", location);
Assert.Contains("https://www.facebook.com/v22.0/dialog/oauth", location);
Assert.Contains("response_type=code", location);
Assert.Contains("client_id=", location);
Assert.Contains("redirect_uri=", location);
Expand Down Expand Up @@ -388,7 +388,7 @@ public async Task PkceSentToTokenEndpoint()
{
Sender = req =>
{
if (req.RequestUri.AbsoluteUri == "https://graph.facebook.com/v14.0/oauth/access_token")
if (req.RequestUri.AbsoluteUri == "https://graph.facebook.com/v22.0/oauth/access_token")
{
var body = req.Content.ReadAsStringAsync().Result;
var form = new FormReader(body);
Expand All @@ -407,7 +407,7 @@ public async Task PkceSentToTokenEndpoint()
token_type = "Bearer",
});
}
else if (req.RequestUri.GetComponents(UriComponents.SchemeAndServer | UriComponents.Path, UriFormat.UriEscaped) == "https://graph.facebook.com/v14.0/me")
else if (req.RequestUri.GetComponents(UriComponents.SchemeAndServer | UriComponents.Path, UriFormat.UriEscaped) == "https://graph.facebook.com/v22.0/me")
{
return ReturnJsonResponse(new
{
Expand All @@ -433,7 +433,7 @@ public async Task PkceSentToTokenEndpoint()
var transaction = await server.SendAsync("https://example.com/challenge");
Assert.Equal(HttpStatusCode.Redirect, transaction.Response.StatusCode);
var locationUri = transaction.Response.Headers.Location;
Assert.StartsWith("https://www.facebook.com/v14.0/dialog/oauth", locationUri.AbsoluteUri);
Assert.StartsWith("https://www.facebook.com/v22.0/dialog/oauth", locationUri.AbsoluteUri);

var queryParams = QueryHelpers.ParseQuery(locationUri.Query);
Assert.False(string.IsNullOrEmpty(queryParams["code_challenge"]));
Expand Down
Loading