-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update webapp
example
#324
Comments
I totally agree with your point, the Except for this point:
I am not sure if we could be beneficial from switching to And we should start to refactor |
Fair enough. I was worried because v0.5.0 hasn't been released yet, but it does seem like the repo is active.
Sorry, I didn't quite understand that. What do you mean? |
Never mind, I just think the work of refactoring the |
Since #305 already got merged, I guess the I tried out the #[get("/topartists")]
fn top_artists(cookies: Cookies) -> AppResponse {
let mut spotify = init_spotify(&cookies);
if !spotify.config.cache_path.exists() {
return AppResponse::Redirect(Redirect::to("/"));
}
let token = spotify.read_token_cache(false).unwrap();
spotify.token = Arc::new(Mutex::new(token));
let top_artists = spotify
.current_user_top_artists(Some(&TimeRange::LongTerm))
.take(10)
.filter_map(Result::ok)
.collect::<Vec<_>>();
if top_artists.is_empty() {
return AppResponse::Redirect(Redirect::to("/"));
}
AppResponse::Json(json!(top_artists))
}
|
Probably you could reproduce this problem with Spotify's Web Console, I guess it's something wrong with your data, e.g. your top artists. https://developer.spotify.com/console/get-current-user-top-artists-and-tracks/ |
Thanks for the hint! I successfully tried out the developer console, so my data seems to be fine. I also tried |
I can reproduce this issue, the problem is that the default scopes in example are https://github.com/ramsayleung/rspotify/blob/master/examples/webapp/src/main.rs#L90 You should add // Please notice that protocol of redirect_uri, make sure it's http
// (or https). It will fail if you mix them up.
let oauth = OAuth {
scopes: scopes!(
"user-read-currently-playing",
"playlist-modify-private",
"user-top-read"
),
redirect_uri: "http://localhost:8000/callback".to_owned(),
..Default::default()
}; it works for me now. |
Thanks for pointing out the scope issue! It works for me now! |
Yeah, I guess that @graves501 ran into that issue because we:
This is something we could improve as well; otherwise we are ignoring possibly important errors. |
Message to comment on stale issues. If none provided, will not mark issues stale |
Is your feature request related to a problem? Please describe.
The
webapp
example could definitely be improved.Describe the solution you'd like
spotify.token = ...
, we can surely avoid that).unwrap
in my opinion.Describe alternatives you've considered
I've fixed a couple things in #305, but it was out of scope.
The text was updated successfully, but these errors were encountered: