Skip to content

Commit cec20e3

Browse files
Pass through CancellationToken
Pass through the CancellationToken for the request into ReadAsStringAsync() calls in the Alipay and Line providers.
1 parent d6c6e7a commit cec20e3

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/AspNet.Security.OAuth.Alipay/AlipayAuthenticationHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ protected override async Task<OAuthTokenResponse> ExchangeCodeAsync([NotNull] OA
8181
"returned a {Status} response with the following payload: {Headers} {Body}.",
8282
/* Status: */ response.StatusCode,
8383
/* Headers: */ response.Headers.ToString(),
84-
/* Body: */ await response.Content.ReadAsStringAsync());
84+
/* Body: */ await response.Content.ReadAsStringAsync(Context.RequestAborted));
8585

8686
return OAuthTokenResponse.Failed(new Exception("An error occurred while retrieving an access token."));
8787
}
@@ -128,7 +128,7 @@ protected override async Task<AuthenticationTicket> CreateTicketAsync(
128128
"returned a {Status} response with the following payload: {Headers} {Body}.",
129129
/* Status: */ response.StatusCode,
130130
/* Headers: */ response.Headers.ToString(),
131-
/* Body: */ await response.Content.ReadAsStringAsync());
131+
/* Body: */ await response.Content.ReadAsStringAsync(Context.RequestAborted));
132132

133133
throw new HttpRequestException("An error occurred while retrieving user information.");
134134
}

src/AspNet.Security.OAuth.Line/LineAuthenticationHandler.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ protected override async Task<OAuthTokenResponse> ExchangeCodeAsync([NotNull] OA
6565
"returned a {Status} response with the following payload: {Headers} {Body}.",
6666
/* Status: */ response.StatusCode,
6767
/* Headers: */ response.Headers.ToString(),
68-
/* Body: */ await response.Content.ReadAsStringAsync());
68+
/* Body: */ await response.Content.ReadAsStringAsync(Context.RequestAborted));
6969

7070
return OAuthTokenResponse.Failed(new Exception("An error occurred while retrieving an access token."));
7171
}
7272

73-
var payload = JsonDocument.Parse(await response.Content.ReadAsStringAsync());
73+
var payload = JsonDocument.Parse(await response.Content.ReadAsStringAsync(Context.RequestAborted));
7474
return OAuthTokenResponse.Success(payload);
7575
}
7676

@@ -90,12 +90,12 @@ protected override async Task<AuthenticationTicket> CreateTicketAsync(
9090
"returned a {Status} response with the following payload: {Headers} {Body}.",
9191
/* Status: */ response.StatusCode,
9292
/* Headers: */ response.Headers.ToString(),
93-
/* Body: */ await response.Content.ReadAsStringAsync());
93+
/* Body: */ await response.Content.ReadAsStringAsync(Context.RequestAborted));
9494

9595
throw new HttpRequestException("An error occurred while retrieving user information.");
9696
}
9797

98-
using var payload = JsonDocument.Parse(await response.Content.ReadAsStringAsync());
98+
using var payload = JsonDocument.Parse(await response.Content.ReadAsStringAsync(Context.RequestAborted));
9999
var principal = new ClaimsPrincipal(identity);
100100
var context = new OAuthCreatingTicketContext(principal, properties, Context, Scheme, Options, Backchannel, tokens, payload.RootElement);
101101
context.RunClaimActions();
@@ -134,12 +134,12 @@ protected override async Task<AuthenticationTicket> CreateTicketAsync(
134134
"the remote server returned a {Status} response with the following payload: {Headers} {Body}.",
135135
/* Status: */ response.StatusCode,
136136
/* Headers: */ response.Headers.ToString(),
137-
/* Body: */ await response.Content.ReadAsStringAsync());
137+
/* Body: */ await response.Content.ReadAsStringAsync(Context.RequestAborted));
138138

139139
throw new HttpRequestException("An error occurred while retrieving the email address associated to the user profile.");
140140
}
141141

142-
using var payload = JsonDocument.Parse(await response.Content.ReadAsStringAsync());
142+
using var payload = JsonDocument.Parse(await response.Content.ReadAsStringAsync(Context.RequestAborted));
143143
return payload.RootElement.GetString("email");
144144
}
145145
}

0 commit comments

Comments
 (0)