Skip to content

Commit 057cf4a

Browse files
authored
examples: Reuse reqwest client in oauth example (#3607)
1 parent 0101c2a commit 057cf4a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

examples/oauth/src/main.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,15 +270,16 @@ async fn login_authorized(
270270
) -> Result<impl IntoResponse, AppError> {
271271
csrf_token_validation_workflow(&query, &cookies, &store).await?;
272272

273+
let client = reqwest::Client::new();
274+
273275
// Get an auth token
274276
let token = oauth_client
275277
.exchange_code(AuthorizationCode::new(query.code.clone()))
276-
.request_async(&reqwest::Client::new())
278+
.request_async(&client)
277279
.await
278280
.context("failed in sending request request to authorization server")?;
279281

280282
// Fetch user data from discord
281-
let client = reqwest::Client::new();
282283
let user_data: User = client
283284
// https://discord.com/developers/docs/resources/user#get-current-user
284285
.get("https://discordapp.com/api/users/@me")

0 commit comments

Comments
 (0)