Struct rspotify_s::ClientCredsSpotify
source · pub struct ClientCredsSpotify {
pub config: Config,
pub creds: Credentials,
pub token: Arc<Mutex<Option<Token>>>,
/* private fields */
}
Expand description
The Client Credentials Flow client for the Spotify API.
This is the most basic flow. It requests a token to Spotify given some
client credentials, without user authorization. The only step to take is to
call Self::request_token
. See this example.
Note: This flow does not include authorization and therefore cannot be used
to access or to manage the endpoints related to user private data in
OAuthClient
.
Fields§
§config: Config
§creds: Credentials
§token: Arc<Mutex<Option<Token>>>
Implementations§
source§impl ClientCredsSpotify
impl ClientCredsSpotify
sourcepub fn new(creds: Credentials) -> Self
pub fn new(creds: Credentials) -> Self
Builds a new ClientCredsSpotify
given a pair of client credentials
and OAuth information.
sourcepub fn from_token(token: Token) -> Self
pub fn from_token(token: Token) -> Self
Build a new ClientCredsSpotify
from an already generated token. Note
that once the token expires this will fail to make requests,
as the client credentials aren’t known.
sourcepub fn with_config(creds: Credentials, config: Config) -> Self
pub fn with_config(creds: Credentials, config: Config) -> Self
Same as Self::new
but with an extra parameter to configure the
client.
sourcepub fn read_token_cache(&self) -> ClientResult<Option<Token>>
pub fn read_token_cache(&self) -> ClientResult<Option<Token>>
Tries to read the cache file’s token.
This will return an error if the token couldn’t be read (e.g. it’s not
available or the JSON is malformed). It may return Ok(None)
if:
- The read token is expired
- The cached token is disabled in the config
sourcepub fn request_token(&self) -> ClientResult<()>
pub fn request_token(&self) -> ClientResult<()>
Obtains the client access token for the app. The resulting token will be saved internally.
Trait Implementations§
source§impl BaseClient for ClientCredsSpotify
impl BaseClient for ClientCredsSpotify
This client has access to the base methods.
source§fn refetch_token(&self) -> ClientResult<Option<Token>>
fn refetch_token(&self) -> ClientResult<Option<Token>>
Note that refetching a token in the Client Credentials flow is equivalent to requesting a token from scratch, since there’s no refresh token available.
fn get_http(&self) -> &HttpClient
source§fn get_token(&self) -> Arc<Mutex<Option<Token>>>
fn get_token(&self) -> Arc<Mutex<Option<Token>>>
Mutex
in order to allow interior
mutability. This is required so that the entire client doesn’t have to
be mutable (the token is accessed to from every endpoint).fn get_creds(&self) -> &Credentials
fn get_config(&self) -> &Config
source§fn auth_url(&self, url: &str) -> String
fn auth_url(&self, url: &str) -> String
source§fn auto_reauth(&self) -> ClientResult<()>
fn auto_reauth(&self) -> ClientResult<()>
source§fn refresh_token(&self) -> ClientResult<()>
fn refresh_token(&self) -> ClientResult<()>
source§fn write_token_cache(&self) -> ClientResult<()>
fn write_token_cache(&self) -> ClientResult<()>
source§fn fetch_access_token(
&self,
payload: &Form<'_>,
headers: Option<&Headers>
) -> ClientResult<Token>
fn fetch_access_token( &self, payload: &Form<'_>, headers: Option<&Headers> ) -> ClientResult<Token>
source§fn track(
&self,
track_id: TrackId<'_>,
market: Option<Market>
) -> ClientResult<FullTrack>
fn track( &self, track_id: TrackId<'_>, market: Option<Market> ) -> ClientResult<FullTrack>
source§fn tracks<'a>(
&self,
track_ids: impl IntoIterator<Item = TrackId<'a>> + Send + 'a,
market: Option<Market>
) -> ClientResult<Vec<FullTrack>>
fn tracks<'a>( &self, track_ids: impl IntoIterator<Item = TrackId<'a>> + Send + 'a, market: Option<Market> ) -> ClientResult<Vec<FullTrack>>
source§fn artist(&self, artist_id: ArtistId<'_>) -> ClientResult<FullArtist>
fn artist(&self, artist_id: ArtistId<'_>) -> ClientResult<FullArtist>
source§fn artists<'a>(
&self,
artist_ids: impl IntoIterator<Item = ArtistId<'a>> + Send + 'a
) -> ClientResult<Vec<FullArtist>>
fn artists<'a>( &self, artist_ids: impl IntoIterator<Item = ArtistId<'a>> + Send + 'a ) -> ClientResult<Vec<FullArtist>>
source§fn artist_albums<'a>(
&'a self,
artist_id: ArtistId<'a>,
include_groups: impl IntoIterator<Item = AlbumType> + Send + Copy + 'a,
market: Option<Market>
) -> Paginator<'_, ClientResult<SimplifiedAlbum>>
fn artist_albums<'a>( &'a self, artist_id: ArtistId<'a>, include_groups: impl IntoIterator<Item = AlbumType> + Send + Copy + 'a, market: Option<Market> ) -> Paginator<'_, ClientResult<SimplifiedAlbum>>
source§fn artist_albums_manual<'a>(
&self,
artist_id: ArtistId<'_>,
include_groups: impl IntoIterator<Item = AlbumType> + Send + 'a,
market: Option<Market>,
limit: Option<u32>,
offset: Option<u32>
) -> ClientResult<Page<SimplifiedAlbum>>
fn artist_albums_manual<'a>( &self, artist_id: ArtistId<'_>, include_groups: impl IntoIterator<Item = AlbumType> + Send + 'a, market: Option<Market>, limit: Option<u32>, offset: Option<u32> ) -> ClientResult<Page<SimplifiedAlbum>>
Self::artist_albums
.source§fn artist_top_tracks(
&self,
artist_id: ArtistId<'_>,
market: Option<Market>
) -> ClientResult<Vec<FullTrack>>
fn artist_top_tracks( &self, artist_id: ArtistId<'_>, market: Option<Market> ) -> ClientResult<Vec<FullTrack>>
source§fn album(
&self,
album_id: AlbumId<'_>,
market: Option<Market>
) -> ClientResult<FullAlbum>
fn album( &self, album_id: AlbumId<'_>, market: Option<Market> ) -> ClientResult<FullAlbum>
source§fn albums<'a>(
&self,
album_ids: impl IntoIterator<Item = AlbumId<'a>> + Send + 'a,
market: Option<Market>
) -> ClientResult<Vec<FullAlbum>>
fn albums<'a>( &self, album_ids: impl IntoIterator<Item = AlbumId<'a>> + Send + 'a, market: Option<Market> ) -> ClientResult<Vec<FullAlbum>>
source§fn search(
&self,
q: &str,
_type: SearchType,
market: Option<Market>,
include_external: Option<IncludeExternal>,
limit: Option<u32>,
offset: Option<u32>
) -> ClientResult<SearchResult>
fn search( &self, q: &str, _type: SearchType, market: Option<Market>, include_external: Option<IncludeExternal>, limit: Option<u32>, offset: Option<u32> ) -> ClientResult<SearchResult>
source§fn album_track<'a>(
&'a self,
album_id: AlbumId<'a>,
market: Option<Market>
) -> Paginator<'_, ClientResult<SimplifiedTrack>>
fn album_track<'a>( &'a self, album_id: AlbumId<'a>, market: Option<Market> ) -> Paginator<'_, ClientResult<SimplifiedTrack>>
source§fn album_track_manual(
&self,
album_id: AlbumId<'_>,
market: Option<Market>,
limit: Option<u32>,
offset: Option<u32>
) -> ClientResult<Page<SimplifiedTrack>>
fn album_track_manual( &self, album_id: AlbumId<'_>, market: Option<Market>, limit: Option<u32>, offset: Option<u32> ) -> ClientResult<Page<SimplifiedTrack>>
Self::album_track
.source§fn user(&self, user_id: UserId<'_>) -> ClientResult<PublicUser>
fn user(&self, user_id: UserId<'_>) -> ClientResult<PublicUser>
source§fn playlist(
&self,
playlist_id: PlaylistId<'_>,
fields: Option<&str>,
market: Option<Market>
) -> ClientResult<FullPlaylist>
fn playlist( &self, playlist_id: PlaylistId<'_>, fields: Option<&str>, market: Option<Market> ) -> ClientResult<FullPlaylist>
source§fn user_playlist(
&self,
user_id: UserId<'_>,
playlist_id: Option<PlaylistId<'_>>,
fields: Option<&str>
) -> ClientResult<FullPlaylist>
fn user_playlist( &self, user_id: UserId<'_>, playlist_id: Option<PlaylistId<'_>>, fields: Option<&str> ) -> ClientResult<FullPlaylist>
source§fn playlist_check_follow(
&self,
playlist_id: PlaylistId<'_>,
user_ids: &[UserId<'_>]
) -> ClientResult<Vec<bool>>
fn playlist_check_follow( &self, playlist_id: PlaylistId<'_>, user_ids: &[UserId<'_>] ) -> ClientResult<Vec<bool>>
source§fn get_a_show(
&self,
id: ShowId<'_>,
market: Option<Market>
) -> ClientResult<FullShow>
fn get_a_show( &self, id: ShowId<'_>, market: Option<Market> ) -> ClientResult<FullShow>
source§fn get_several_shows<'a>(
&self,
ids: impl IntoIterator<Item = ShowId<'a>> + Send + 'a,
market: Option<Market>
) -> ClientResult<Vec<SimplifiedShow>>
fn get_several_shows<'a>( &self, ids: impl IntoIterator<Item = ShowId<'a>> + Send + 'a, market: Option<Market> ) -> ClientResult<Vec<SimplifiedShow>>
source§fn get_shows_episodes<'a>(
&'a self,
id: ShowId<'a>,
market: Option<Market>
) -> Paginator<'_, ClientResult<SimplifiedEpisode>>
fn get_shows_episodes<'a>( &'a self, id: ShowId<'a>, market: Option<Market> ) -> Paginator<'_, ClientResult<SimplifiedEpisode>>
source§fn get_shows_episodes_manual(
&self,
id: ShowId<'_>,
market: Option<Market>,
limit: Option<u32>,
offset: Option<u32>
) -> ClientResult<Page<SimplifiedEpisode>>
fn get_shows_episodes_manual( &self, id: ShowId<'_>, market: Option<Market>, limit: Option<u32>, offset: Option<u32> ) -> ClientResult<Page<SimplifiedEpisode>>
Self::get_shows_episodes
.source§fn get_an_episode(
&self,
id: EpisodeId<'_>,
market: Option<Market>
) -> ClientResult<FullEpisode>
fn get_an_episode( &self, id: EpisodeId<'_>, market: Option<Market> ) -> ClientResult<FullEpisode>
source§fn get_several_episodes<'a>(
&self,
ids: impl IntoIterator<Item = EpisodeId<'a>> + Send + 'a,
market: Option<Market>
) -> ClientResult<Vec<FullEpisode>>
fn get_several_episodes<'a>( &self, ids: impl IntoIterator<Item = EpisodeId<'a>> + Send + 'a, market: Option<Market> ) -> ClientResult<Vec<FullEpisode>>
source§fn track_features(&self, track_id: TrackId<'_>) -> ClientResult<AudioFeatures>
fn track_features(&self, track_id: TrackId<'_>) -> ClientResult<AudioFeatures>
source§fn tracks_features<'a>(
&self,
track_ids: impl IntoIterator<Item = TrackId<'a>> + Send + 'a
) -> ClientResult<Option<Vec<AudioFeatures>>>
fn tracks_features<'a>( &self, track_ids: impl IntoIterator<Item = TrackId<'a>> + Send + 'a ) -> ClientResult<Option<Vec<AudioFeatures>>>
source§fn track_analysis(&self, track_id: TrackId<'_>) -> ClientResult<AudioAnalysis>
fn track_analysis(&self, track_id: TrackId<'_>) -> ClientResult<AudioAnalysis>
source§fn categories<'a>(
&'a self,
locale: Option<&'a str>,
country: Option<Market>
) -> Paginator<'_, ClientResult<Category>>
fn categories<'a>( &'a self, locale: Option<&'a str>, country: Option<Market> ) -> Paginator<'_, ClientResult<Category>>
source§fn categories_manual(
&self,
locale: Option<&str>,
country: Option<Market>,
limit: Option<u32>,
offset: Option<u32>
) -> ClientResult<Page<Category>>
fn categories_manual( &self, locale: Option<&str>, country: Option<Market>, limit: Option<u32>, offset: Option<u32> ) -> ClientResult<Page<Category>>
Self::categories
.source§fn category_playlists<'a>(
&'a self,
category_id: &'a str,
country: Option<Market>
) -> Paginator<'_, ClientResult<SimplifiedPlaylist>>
fn category_playlists<'a>( &'a self, category_id: &'a str, country: Option<Market> ) -> Paginator<'_, ClientResult<SimplifiedPlaylist>>
source§fn category_playlists_manual(
&self,
category_id: &str,
country: Option<Market>,
limit: Option<u32>,
offset: Option<u32>
) -> ClientResult<Page<SimplifiedPlaylist>>
fn category_playlists_manual( &self, category_id: &str, country: Option<Market>, limit: Option<u32>, offset: Option<u32> ) -> ClientResult<Page<SimplifiedPlaylist>>
Self::category_playlists
.source§fn featured_playlists(
&self,
locale: Option<&str>,
country: Option<Market>,
timestamp: Option<DateTime<Utc>>,
limit: Option<u32>,
offset: Option<u32>
) -> ClientResult<FeaturedPlaylists>
fn featured_playlists( &self, locale: Option<&str>, country: Option<Market>, timestamp: Option<DateTime<Utc>>, limit: Option<u32>, offset: Option<u32> ) -> ClientResult<FeaturedPlaylists>
source§fn new_releases(
&self,
country: Option<Market>
) -> Paginator<'_, ClientResult<SimplifiedAlbum>>
fn new_releases( &self, country: Option<Market> ) -> Paginator<'_, ClientResult<SimplifiedAlbum>>
source§fn new_releases_manual(
&self,
country: Option<Market>,
limit: Option<u32>,
offset: Option<u32>
) -> ClientResult<Page<SimplifiedAlbum>>
fn new_releases_manual( &self, country: Option<Market>, limit: Option<u32>, offset: Option<u32> ) -> ClientResult<Page<SimplifiedAlbum>>
Self::new_releases
.source§fn recommendations<'a>(
&self,
attributes: impl IntoIterator<Item = RecommendationsAttribute> + Send + 'a,
seed_artists: Option<impl IntoIterator<Item = ArtistId<'a>> + Send + 'a>,
seed_genres: Option<impl IntoIterator<Item = &'a str> + Send + 'a>,
seed_tracks: Option<impl IntoIterator<Item = TrackId<'a>> + Send + 'a>,
market: Option<Market>,
limit: Option<u32>
) -> ClientResult<Recommendations>
fn recommendations<'a>( &self, attributes: impl IntoIterator<Item = RecommendationsAttribute> + Send + 'a, seed_artists: Option<impl IntoIterator<Item = ArtistId<'a>> + Send + 'a>, seed_genres: Option<impl IntoIterator<Item = &'a str> + Send + 'a>, seed_tracks: Option<impl IntoIterator<Item = TrackId<'a>> + Send + 'a>, market: Option<Market>, limit: Option<u32> ) -> ClientResult<Recommendations>
source§fn playlist_items<'a>(
&'a self,
playlist_id: PlaylistId<'a>,
fields: Option<&'a str>,
market: Option<Market>
) -> Paginator<'_, ClientResult<PlaylistItem>>
fn playlist_items<'a>( &'a self, playlist_id: PlaylistId<'a>, fields: Option<&'a str>, market: Option<Market> ) -> Paginator<'_, ClientResult<PlaylistItem>>
source§fn playlist_items_manual(
&self,
playlist_id: PlaylistId<'_>,
fields: Option<&str>,
market: Option<Market>,
limit: Option<u32>,
offset: Option<u32>
) -> ClientResult<Page<PlaylistItem>>
fn playlist_items_manual( &self, playlist_id: PlaylistId<'_>, fields: Option<&str>, market: Option<Market>, limit: Option<u32>, offset: Option<u32> ) -> ClientResult<Page<PlaylistItem>>
Self::playlist_items
.source§fn user_playlists<'a>(
&'a self,
user_id: UserId<'a>
) -> Paginator<'_, ClientResult<SimplifiedPlaylist>>
fn user_playlists<'a>( &'a self, user_id: UserId<'a> ) -> Paginator<'_, ClientResult<SimplifiedPlaylist>>
source§fn user_playlists_manual(
&self,
user_id: UserId<'_>,
limit: Option<u32>,
offset: Option<u32>
) -> ClientResult<Page<SimplifiedPlaylist>>
fn user_playlists_manual( &self, user_id: UserId<'_>, limit: Option<u32>, offset: Option<u32> ) -> ClientResult<Page<SimplifiedPlaylist>>
Self::user_playlists
.source§impl Clone for ClientCredsSpotify
impl Clone for ClientCredsSpotify
source§fn clone(&self) -> ClientCredsSpotify
fn clone(&self) -> ClientCredsSpotify
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more