bogpan / spotify-rs Goto Github PK
View Code? Open in Web Editor NEWRust wrapper for the Spotify API.
Home Page: https://crates.io/crates/spotify-rs
License: Apache License 2.0
Rust wrapper for the Spotify API.
Home Page: https://crates.io/crates/spotify-rs
License: Apache License 2.0
Provide examples in an Examples/
directory. That show how to use this lib.
I am generating a URL for the user to log into via
use dotenvy::dotenv;
use spotify_rs::{AuthCodeClient, AuthCodeFlow, ClientCredsClient, ClientCredsFlow, RedirectUrl};
use std::{env, error::Error};
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
// This should match the redirect URI you set in your app's settings
let redirect_url = RedirectUrl::new("http://localhost:3000".to_owned()).unwrap();
let auto_refresh = true;
let scopes = vec!["user-library-read", "playlist-read-private"];
let _ = dotenv();
let client_secret = env::var("spotify_client_secret").expect("CLIENT_SECRET must be set");
let auth_code_flow =
AuthCodeFlow::new("0079fab38fc74726ac22609e5f996898", client_secret, scopes);
// Redirect the user to this URL to get the auth code and CSRF token
let (client, url) = AuthCodeClient::new(auth_code_flow, redirect_url, auto_refresh);
println!("Please visit this URL: {}", url);
After clicking the URL, and manually logging in, I am redirected to: http://localhost:3000/?code=...&state=...
(where ...
are codes.
I am passing code
to "auth_code"
and state
to "csrf_token"
, in the
let mut spotify = client
.authenticate("auth_code", "csrf_token")
.await
.unwrap();
function. But as a result I get
`Err` value: InvalidStateParameter
Is this an error in this lib or am I doing something wrong?
I see functions to get albums and tracks by ID. But not a way to play them.
Hi, I'm currently using your API bindings to implement a project and am very happy for your work.
One thing that bothers me though: when querying things that require pagination, you return the beautiful Page<>
struct, but you don't offer any methods for conveniently fetching the next/previous page (or at least I couldn't figure out how). This means an index calculation based of the information in the response is required, followed by a whole more run through the builder setup.
I would like to offer my help in implementing this functionality if you are interested :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.