File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
src/AspNet.Security.OAuth.Vkontakte Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,19 @@ protected override async Task<AuthenticationTicket> CreateTicketAsync(
4949 }
5050
5151 using var container = JsonDocument . Parse ( await response . Content . ReadAsStringAsync ( Context . RequestAborted ) ) ;
52- using var enumerator = container . RootElement . GetProperty ( "response" ) . EnumerateArray ( ) ;
52+
53+ if ( ! container . RootElement . TryGetProperty ( "response" , out var profileResponse ) )
54+ {
55+ if ( container . RootElement . TryGetProperty ( "error" , out var error ) &&
56+ error . ValueKind is JsonValueKind . String )
57+ {
58+ throw new InvalidOperationException ( $ "An error occurred while retrieving the user profile: { error . GetString ( ) } ") ;
59+ }
60+
61+ throw new InvalidOperationException ( "An error occurred while retrieving the user profile." ) ;
62+ }
63+
64+ using var enumerator = profileResponse . EnumerateArray ( ) ;
5365 var payload = enumerator . First ( ) ;
5466
5567 var principal = new ClaimsPrincipal ( identity ) ;
You can’t perform that action at this time.
0 commit comments