|
1 | | -use std::str::FromStr; |
2 | | -use serde_with::DurationSeconds; |
3 | | -use std::time::Duration; |
| 1 | +use crate::axum::url_encode; |
| 2 | +use crate::commands::twitch_service::OauthCredential; |
| 3 | +use crate::service_oauth::oauth_service::OAuthService; |
4 | 4 | use anyhow::Context; |
5 | 5 | use axum::http::method::Method; |
6 | 6 | use axum::http::StatusCode; |
7 | 7 | use serde::{Deserialize, Serialize}; |
8 | 8 | use serde_with::serde_as; |
9 | | -use sqlx::types::chrono::{DateTime, Local, NaiveDateTime}; |
| 9 | +use serde_with::DurationSeconds; |
| 10 | +use sqlx::types::chrono::Local; |
| 11 | +use std::str::FromStr; |
| 12 | +use std::time::Duration; |
10 | 13 | use url::Url; |
11 | | -use crate::axum::url_encode; |
12 | | -use crate::commands::twitch_service::OauthCredential; |
13 | | -use crate::service_oauth::oauth_service::OAuthService; |
14 | 14 |
|
15 | 15 | #[serde_as] |
16 | 16 | #[derive(Deserialize)] |
@@ -53,7 +53,7 @@ pub async fn validate_token(access_token: impl AsRef<str>) -> anyhow::Result<Opt |
53 | 53 | .build() |
54 | 54 | .context("Failed to build client builder for twitch access token validation")? |
55 | 55 | .request(Method::GET, "https://id.twitch.tv/oauth2/validate") |
56 | | - .header("Authorization", format!("Bearer {}", access_token)) |
| 56 | + .header("Authorization", format!("Bearer {}", access_token.as_ref())) |
57 | 57 | .send() |
58 | 58 | .await |
59 | 59 | .context("Failed to send access token validation request to twitch")?; |
@@ -82,9 +82,9 @@ pub async fn refresh_token(refresh_token: impl AsRef<str>, client_id: impl AsRef |
82 | 82 | .context("Failed to build client builder for refreshing twitch oauth token")? |
83 | 83 | .request(Method::GET, "https://id.twitch.tv/oauth2/token") |
84 | 84 | .json(&RefreshRequest { |
85 | | - refresh_token, |
86 | | - client_id, |
87 | | - client_secret, |
| 85 | + refresh_token: refresh_token.as_ref(), |
| 86 | + client_id: client_id.as_ref(), |
| 87 | + client_secret: client_secret.as_ref(), |
88 | 88 | grant_type: "refresh_token", |
89 | 89 | }) |
90 | 90 | .send() |
|
0 commit comments