[−][src]Crate spotify_oauth
Spotify OAuth
An implementation of the Spotify Authorization Code Flow in Rust.
Basic Example
use std::io::stdin; use std::str::FromStr; use spotify_oauth::{SpotifyAuth, SpotifyCallback, SpotifyScope}; fn main() -> Result<(), Box<std::error::Error>> { // Setup Spotify Auth URL let auth = SpotifyAuth::new_from_env("code".into(), vec![SpotifyScope::Streaming], false); let auth_url = auth.authorize_url()?; // Open the auth URL in the default browser of the user. open::that(auth_url)?; println!("Input callback URL:"); let mut buffer = String::new(); stdin().read_line(&mut buffer)?; let token = SpotifyCallback::from_str(buffer.trim())?.convert_into_token(auth.client_id, auth.client_secret, auth.redirect_uri)?; println!("Token: {:#?}", token); Ok(()) }
Structs
SpotifyAuth | Spotify Authentication |
SpotifyCallback | The Spotify Callback URL |
SpotifyToken | The Spotify Token object. |
Enums
SpotifyScope | Spotify Scopes for the API. This enum implements FromStr and ToString / Display through strum. |
Functions
datetime_to_timestamp | Convert date and time to a unix timestamp. |
generate_random_string | Generate a random alphanumeric string with a given length. |