[−][src]Struct spotify_oauth::SpotifyCallback
The Spotify Callback URL
This struct follows the parameters given at this link.
The main use of this object is to convert the callback URL into an object that can be used to generate a token.
If needed you can also create this callback object using the new
function in the struct.
Example
use spotify_oauth::SpotifyCallback; use std::str::FromStr; // Create a new spotify callback object using the callback url given by the authorization process. // This object can then be converted into the token needed for the application. let callback = SpotifyCallback::from_str("https://example.com/callback?code=NApCCgBkWtQ&state=test").unwrap(); assert_eq!(callback, SpotifyCallback::new(Some("NApCCgBkWtQ".to_string()), None, String::from("test")));
Methods
impl SpotifyCallback
[src]
Conversion and helper functions for SpotifyCallback.
pub fn new(code: Option<String>, error: Option<String>, state: String) -> Self
[src]
Create a new Spotify Callback object with given values.
Example
use spotify_oauth::SpotifyCallback; // Create a new spotify callback object using the new function. // This object can then be converted into the token needed for the application. let callback = SpotifyCallback::new(Some("NApCCgBkWtQ".to_string()), None, String::from("test"));
pub fn convert_into_token(
self,
client_id: String,
client_secret: String,
redirect_uri: Url
) -> Result<SpotifyToken, SpotifyError>
[src]
self,
client_id: String,
client_secret: String,
redirect_uri: Url
) -> Result<SpotifyToken, SpotifyError>
Converts the Spotify Callback object into a Spotify Token object.
Example
use spotify_oauth::{SpotifyAuth, SpotifyCallback, SpotifyScope}; use std::str::FromStr; // Create a new Spotify auth object. let auth = SpotifyAuth::new("00000000000".into(), "secret".into(), "code".into(), "http://localhost:8000/callback".into(), vec![SpotifyScope::Streaming], false); // Create a new spotify callback object using the callback url given by the authorization process and convert it into a token. let token = SpotifyCallback::from_str("https://example.com/callback?code=NApCCgBkWtQ&state=test").unwrap() .convert_into_token(auth.client_id, auth.client_secret, auth.redirect_uri);
Trait Implementations
impl PartialEq<SpotifyCallback> for SpotifyCallback
[src]
fn eq(&self, other: &SpotifyCallback) -> bool
[src]
fn ne(&self, other: &SpotifyCallback) -> bool
[src]
impl Debug for SpotifyCallback
[src]
impl FromStr for SpotifyCallback
[src]
Implementation of FromStr for Spotify Callback URLs.
Example
use spotify_oauth::SpotifyCallback; use std::str::FromStr; // Create a new spotify callback object using the callback url given by the authorization process. // This object can then be converted into the token needed for the application. let callback = SpotifyCallback::from_str("https://example.com/callback?code=NApCCgBkWtQ&state=test").unwrap(); assert_eq!(callback, SpotifyCallback::new(Some("NApCCgBkWtQ".to_string()), None, String::from("test")));
Auto Trait Implementations
impl Unpin for SpotifyCallback
impl Sync for SpotifyCallback
impl Send for SpotifyCallback
impl UnwindSafe for SpotifyCallback
impl RefUnwindSafe for SpotifyCallback
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,
fn vzip(self) -> V
impl<T> Erased for T
impl<'a, T> TryFrom<&'a str> for T where
T: FromStr,
T: FromStr,
type Err = <T as FromStr>::Err
fn try_from(string: &'a str) -> Result<T, <T as TryFrom<&'a str>>::Err>
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
U: TryFrom<T>,