Skip to content

Commit

Permalink
Auto refresh spotify tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
Petrosz007 committed Jul 2, 2023
1 parent f8c8078 commit 3e854bd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 0 additions & 1 deletion backend/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use std::{
};

use axum::{
debug_handler,
extract::{Query, State},
http::{Method, StatusCode},
response::IntoResponse,
Expand Down
8 changes: 6 additions & 2 deletions backend/src/spotify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use itertools::Itertools;
use rspotify::{
model::{ArtistId, IdError, PlaylistId, TrackId},
prelude::BaseClient,
ClientCredsSpotify, ClientError, Credentials,
ClientCredsSpotify, ClientError, Config, Credentials,
};
use thiserror::Error;

Expand All @@ -27,8 +27,12 @@ pub struct SpotifyClient {
impl SpotifyClient {
pub async fn new(client_id: &str, client_secret: &str) -> SpotifyClient {
let creds = Credentials::new(client_id, client_secret);
let config = Config {
token_refreshing: true,
..Default::default()
};

let spotify = ClientCredsSpotify::new(creds);
let spotify = ClientCredsSpotify::with_config(creds, config);

spotify.request_token().await.unwrap();

Expand Down

0 comments on commit 3e854bd

Please sign in to comment.