@@ -99,20 +99,29 @@ protected override async Task<AuthenticationTicket> CreateTicketAsync(
9999 /// <returns>A <see cref="JsonDocument"/> containing the detailed user information.</returns>
100100 protected virtual async Task < JsonDocument > GetDetailedUserInfoAsync ( [ NotNull ] OAuthTokenResponse tokens , long userId )
101101 {
102- var userDetailsUrl = string . Format ( null , EtsyAuthenticationDefaults . DetailedUserInfoEndpoint , userId ) ;
102+ string userDetailsUrl ;
103+ if ( ! string . IsNullOrWhiteSpace ( Options . DetailedUserInfoEndpoint ) )
104+ {
105+ userDetailsUrl = string . Format ( CultureInfo . InvariantCulture , Options . DetailedUserInfoEndpoint , userId ) ;
106+ }
107+ else
108+ {
109+ userDetailsUrl = string . Format ( CultureInfo . InvariantCulture , EtsyAuthenticationDefaults . DetailedUserInfoEndpoint , userId ) ;
110+ }
111+
103112 using var request = new HttpRequestMessage ( HttpMethod . Get , userDetailsUrl ) ;
104113 request . Headers . Accept . Add ( new MediaTypeWithQualityHeaderValue ( MediaTypeNames . Application . Json ) ) ;
105114 request . Headers . Authorization = new AuthenticationHeaderValue ( "Bearer" , tokens . AccessToken ) ;
106115 request . Headers . Add ( "x-api-key" , Options . ClientId ) ;
107116
108- using var userResponse = await Backchannel . SendAsync ( request , HttpCompletionOption . ResponseHeadersRead , Context . RequestAborted ) ;
109- if ( ! userResponse . IsSuccessStatusCode )
117+ using var response = await Backchannel . SendAsync ( request , HttpCompletionOption . ResponseHeadersRead , Context . RequestAborted ) ;
118+ if ( ! response . IsSuccessStatusCode )
110119 {
111- await Log . UserProfileErrorAsync ( Logger , userResponse , Context . RequestAborted ) ;
120+ await Log . UserProfileErrorAsync ( Logger , response , Context . RequestAborted ) ;
112121 throw new HttpRequestException ( "An error occurred while retrieving detailed user info from Etsy." ) ;
113122 }
114123
115- return JsonDocument . Parse ( await userResponse . Content . ReadAsStringAsync ( Context . RequestAborted ) ) ;
124+ return JsonDocument . Parse ( await response . Content . ReadAsStringAsync ( Context . RequestAborted ) ) ;
116125 }
117126
118127 private static partial class Log
0 commit comments