use rspotify::{prelude::*, scopes, AuthCodeSpotify, Credentials, OAuth};
#[tokio::main]
async fn main() {
env_logger::init();
let creds = Credentials::from_env().unwrap();
let scopes = scopes!(
"user-read-email",
"user-read-private",
"user-top-read",
"user-read-recently-played",
"user-follow-read",
"user-library-read",
"user-read-currently-playing",
"user-read-playback-state",
"user-read-playback-position",
"playlist-read-collaborative",
"playlist-read-private",
"user-follow-modify",
"user-library-modify",
"user-modify-playback-state",
"playlist-modify-public",
"playlist-modify-private",
"ugc-image-upload"
);
let oauth = OAuth::from_env(scopes).unwrap();
let spotify = AuthCodeSpotify::new(creds, oauth);
let url = spotify.get_authorize_url(false).unwrap();
spotify.prompt_for_token(&url).await.unwrap();
let token = spotify.token.lock().await.unwrap();
println!("Access token: {}", &token.as_ref().unwrap().access_token);
println!(
"Refresh token: {}",
token.as_ref().unwrap().refresh_token.as_ref().unwrap()
);
}