@@ -25,6 +25,14 @@ public EtsyAuthenticationHandler(
2525 {
2626 }
2727
28+ /// <summary>
29+ /// Creates an <see cref="AuthenticationTicket"/> from the OAuth tokens and Etsy user information.
30+ /// </summary>
31+ /// <param name="identity">The claims identity to populate.</param>
32+ /// <param name="properties">The authentication properties.</param>
33+ /// <param name="tokens">The OAuth token response containing the access token.</param>
34+ /// <returns>An <see cref="AuthenticationTicket"/> containing the user claims and properties.</returns>
35+ /// <exception cref="HttpRequestException">Thrown when an error occurs while retrieving user information from Etsy.</exception>
2836 protected override async Task < AuthenticationTicket > CreateTicketAsync (
2937 [ NotNull ] ClaimsIdentity identity ,
3038 [ NotNull ] AuthenticationProperties properties ,
@@ -49,7 +57,6 @@ protected override async Task<AuthenticationTicket> CreateTicketAsync(
4957 // Extract user_id and shop_id from the /me response
5058 // Both fields should always be present in a successful Etsy OAuth response
5159 var userId = meRoot . GetProperty ( "user_id" ) . GetInt64 ( ) ;
52- var shopId = meRoot . GetProperty ( "shop_id" ) . GetInt64 ( ) ;
5360
5461 var principal = new ClaimsPrincipal ( identity ) ;
5562 var context = new OAuthCreatingTicketContext ( principal , properties , Context , Scheme , Options , Backchannel , tokens , meRoot ) ;
@@ -69,13 +76,11 @@ protected override async Task<AuthenticationTicket> CreateTicketAsync(
6976 foreach ( var action in Options . ClaimActions )
7077 {
7178 // Skip the action if it's a JsonKeyClaimAction for user_id or shop_id
72- if ( action is Microsoft . AspNetCore . Authentication . OAuth . Claims . JsonKeyClaimAction jsonAction )
79+ if ( action is Microsoft . AspNetCore . Authentication . OAuth . Claims . JsonKeyClaimAction { ClaimType : var t } &&
80+ ( t == ClaimTypes . NameIdentifier
81+ || t == EtsyAuthenticationConstants . Claims . ShopId ) )
7382 {
74- if ( jsonAction . ClaimType == ClaimTypes . NameIdentifier ||
75- jsonAction . ClaimType == EtsyAuthenticationConstants . Claims . ShopId )
76- {
77- continue ;
78- }
83+ continue ;
7984 }
8085
8186 action . Run ( detailedRoot , identity , Options . ClaimsIssuer ?? ClaimsIssuer ) ;
@@ -91,7 +96,7 @@ protected override async Task<AuthenticationTicket> CreateTicketAsync(
9196 /// </summary>
9297 /// <param name="tokens">The OAuth token response.</param>
9398 /// <param name="userId">The user ID to retrieve details for.</param>
94- /// <returns>A JSON document containing the detailed user information.</returns>
99+ /// <returns>A <see cref="JsonDocument"/> containing the detailed user information.</returns>
95100 protected virtual async Task < JsonDocument > GetDetailedUserInfoAsync ( [ NotNull ] OAuthTokenResponse tokens , long userId )
96101 {
97102 var userDetailsUrl = string . Format ( null , EtsyAuthenticationDefaults . DetailedUserInfoEndpoint , userId ) ;
0 commit comments