-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:samrayleung/rspotify
- Loading branch information
Showing
11 changed files
with
130 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
extern crate rspotify; | ||
|
||
use rspotify::spotify::client::Spotify; | ||
use rspotify::spotify::util::get_token; | ||
use rspotify::spotify::oauth2::{SpotifyClientCredentials, SpotifyOAuth}; | ||
|
||
fn main() { | ||
// Set client_id and client_secret in .env file or | ||
// export CLIENT_ID="your client_id" | ||
// export CLIENT_SECRET="secret" | ||
// export REDIRECT_URI=your-direct-uri | ||
|
||
// Or set client_id, client_secret,redirect_uri explictly | ||
// let oauth = SpotifyOAuth::default() | ||
// .client_id("this-is-my-client-id") | ||
// .client_secret("this-is-my-client-secret") | ||
// .redirect_uri("http://localhost:8888/callback") | ||
// .build(); | ||
|
||
let mut spotify_oauth = SpotifyOAuth::default().build(); | ||
match get_token(&mut spotify_oauth){ | ||
Some(token_info) => { | ||
let client_credential = SpotifyClientCredentials::default() | ||
.token_info(token_info) | ||
.build(); | ||
|
||
// Or set client_id and client_secret explictly | ||
// let client_credential = SpotifyClientCredentials::default() | ||
// .client_id("this-is-my-client-id") | ||
// .client_secret("this-is-my-client-secret") | ||
// .build(); | ||
let spotify = Spotify::default() | ||
.client_credentials_manager(client_credential) | ||
.build(); | ||
let playlist_id = String::from("59ZbFPES4DQwEjBpWHzrtC"); | ||
let playlists = spotify.playlist(&playlist_id, None, None); | ||
println!("{:?}", playlists); | ||
|
||
} | ||
None => println!("auth failed"), | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
extern crate reqwest; | ||
extern crate rspotify; | ||
use rspotify::spotify::client::Spotify; | ||
use rspotify::spotify::oauth2::SpotifyClientCredentials; | ||
use reqwest::Client; | ||
|
||
//TODO waitting for mutable mockito test framework | ||
#[test]#[ignore] | ||
fn test_device(){ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.