[−][src]Struct spotify_oauth::SpotifyAuth
Spotify Authentication
This struct follows the parameters given at this link.
Example
// Create a new spotify auth object with the scope "Streaming" using the ``new_from_env`` function. // This object can then be converted into the auth url needed to gain a callback for the token. let auth = SpotifyAuth::new_from_env("code".into(), vec![SpotifyScope::Streaming], false);
Fields
client_id: String
The Spotify Application Client ID
client_secret: String
The Spotify Application Client Secret
response_type: String
Required by the Spotify API.
redirect_uri: Url
The URI to redirect to after the user grants or denies permission.
state: String
A random generated string that can be useful for correlating requests and responses.
scope: Vec<SpotifyScope>
Vec of Spotify Scopes.
show_dialog: bool
Whether or not to force the user to approve the app again if they’ve already done so.
Methods
impl SpotifyAuth
[src]
Conversion and helper functions for SpotifyAuth.
pub fn new(
client_id: String,
client_secret: String,
response_type: String,
redirect_uri: String,
scope: Vec<SpotifyScope>,
show_dialog: bool
) -> Self
[src]
client_id: String,
client_secret: String,
response_type: String,
redirect_uri: String,
scope: Vec<SpotifyScope>,
show_dialog: bool
) -> Self
Generate a new SpotifyAuth structure from values in memory.
This function loads SPOTIFY_CLIENT_ID
and SPOTIFY_REDIRECT_ID
from values given in
function parameters.
This function also automatically generates a state value of length 20 using a random string generator.
Example
// SpotifyAuth with the scope "Streaming". let auth = SpotifyAuth::new("00000000000".into(), "secret".into(), "code".into(), "http://localhost:8000/callback".into(), vec![SpotifyScope::Streaming], false);
pub fn new_from_env(
response_type: String,
scope: Vec<SpotifyScope>,
show_dialog: bool
) -> Self
[src]
response_type: String,
scope: Vec<SpotifyScope>,
show_dialog: bool
) -> Self
Generate a new SpotifyAuth structure from values in the environment.
This function loads SPOTIFY_CLIENT_ID
and SPOTIFY_REDIRECT_ID
from the environment.
This function also automatically generates a state value of length 20 using a random string generator.
Example
// SpotifyAuth with the scope "Streaming". let auth = SpotifyAuth::new_from_env("code".into(), vec![SpotifyScope::Streaming], false);
pub fn scope_into_string(&self) -> String
[src]
Concatenate the scope vector into a string needed for the authorization URL.
Example
// Default SpotifyAuth with the scope "Streaming". let auth = SpotifyAuth::new("00000000000".into(), "secret".into(), "code".into(), "http://localhost:8000/callback".into(), vec![SpotifyScope::Streaming], false);
pub fn authorize_url(&self) -> Result<String, SpotifyError>
[src]
Convert the SpotifyAuth struct into the authorization URL.
More information on this URL can be found here.
Example
// Default SpotifyAuth with the scope "Streaming" converted into the authorization URL. let auth = SpotifyAuth::new("00000000000".into(), "secret".into(), "code".into(), "http://localhost:8000/callback".into(), vec![SpotifyScope::Streaming], false) .authorize_url().unwrap();
Trait Implementations
impl Default for SpotifyAuth
[src]
Implementation of Default for SpotifyAuth.
If CLIENT_ID
is not found in the .env
in the project directory it will default to INVALID_ID
.
If REDIRECT_ID
is not found in the .env
in the project directory it will default to http://localhost:8000/callback
.
This implementation automatically generates a state value of length 20 using a random string generator.
Auto Trait Implementations
impl RefUnwindSafe for SpotifyAuth
impl Send for SpotifyAuth
impl Sync for SpotifyAuth
impl Unpin for SpotifyAuth
impl UnwindSafe for SpotifyAuth
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
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> 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<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,