Skip to content

Commit beda821

Browse files
committed
Update google oauth user info endpoint to v3 dotnet#4684
1 parent b6a10c6 commit beda821

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

src/Security/Authentication/Google/src/GoogleDefaults.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,5 @@ public static class GoogleDefaults
3434
/// <summary>
3535
/// The Google endpoint that is used to gather additional user information.
3636
/// </summary>
37-
/// <remarks>
38-
/// For more details about this endpoint, see <see href="https://developers.google.com/apis-explorer/#search/oauth2/oauth2/v2/"/>.
39-
/// </remarks>
40-
public static readonly string UserInformationEndpoint = "https://www.googleapis.com/oauth2/v2/userinfo";
37+
public static readonly string UserInformationEndpoint = "https://www.googleapis.com/oauth2/v3/userinfo";
4138
}

src/Security/Authentication/Google/src/GoogleOptions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ public GoogleOptions()
2525
Scope.Add("profile");
2626
Scope.Add("email");
2727

28-
ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "id");
28+
ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "id"); // v2
29+
ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "sub"); // v3
2930
ClaimActions.MapJsonKey(ClaimTypes.Name, "name");
3031
ClaimActions.MapJsonKey(ClaimTypes.GivenName, "given_name");
3132
ClaimActions.MapJsonKey(ClaimTypes.Surname, "family_name");

src/Security/Authentication/test/GoogleTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,11 +1026,11 @@ private HttpMessageHandler CreateBackchannel()
10261026
refresh_token = "Test Refresh Token"
10271027
});
10281028
}
1029-
else if (req.RequestUri.GetComponents(UriComponents.SchemeAndServer | UriComponents.Path, UriFormat.UriEscaped) == "https://www.googleapis.com/oauth2/v2/userinfo")
1029+
else if (req.RequestUri.GetComponents(UriComponents.SchemeAndServer | UriComponents.Path, UriFormat.UriEscaped) == "https://www.googleapis.com/oauth2/v3/userinfo")
10301030
{
10311031
return ReturnJsonResponse(new
10321032
{
1033-
id = "Test User ID",
1033+
sub = "Test User ID",
10341034
name = "Test Name",
10351035
given_name = "Test Given Name",
10361036
family_name = "Test Family Name",

0 commit comments

Comments
 (0)