forked from
rocksky.app/rocksky
A decentralized music tracking and discovery platform built on AT Protocol 馃幍
1use anyhow::Error;
2use reqwest::Client;
3use types::AccessToken;
4
5pub mod client;
6pub mod types;
7
8pub async fn refresh_token(
9 token: &str,
10 client_id: &str,
11 client_secret: &str,
12) -> Result<AccessToken, Error> {
13 let client = Client::new();
14
15 let response = client
16 .post("https://accounts.spotify.com/api/token")
17 .basic_auth(&client_id, Some(client_secret))
18 .form(&[
19 ("grant_type", "refresh_token"),
20 ("refresh_token", token),
21 ("client_id", &client_id),
22 ])
23 .send()
24 .await?;
25 let token = response.json::<AccessToken>().await?;
26 Ok(token)
27}