-
Notifications
You must be signed in to change notification settings - Fork 126
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
Use Oauth2 login with spotify #731
base: development
Are you sure you want to change the base?
Conversation
…ifyId::from_base62` is setting this to unkown which causes playback to fail with ` Unable to load audio item: Error { kind: Unavailable, error: NonPlayable } / unable to load track <SpotifyId("spotify:unknown:1iI5J72TQxYdQkKnkRwWCn")>`
…e URL in the default browser
That flatpak builder failure looks like clippy complaining about pre-existing code. Is this a new thing? |
tested it on my pinephone too and I have tunes :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but it should work with librespot 0.6.0 too which is also what I run on my OS currently
but thanks for the fix it works now :))))
You must have commented 0.6.0 within days of it's release :') I'll give it a go and see how it works. I was actually looking at the login5 stuff on librespot too as it may fix the other authentication issue.... |
I also tested it locally and it seems it's working quite well. I would remove the old login button. @xou816 Could you review? |
Looks like a lot of great work, I'll try to review that tomorrow, thanks! |
Looks good overall! I would have a few things to nitpick but nothing major/no reason to delay this. Just hesitant about the client id change, is it needed? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(nothing blocking, just want to discuss the client id real quick)
@@ -278,7 +311,8 @@ impl SpotifyPlayer { | |||
} | |||
} | |||
|
|||
const CLIENT_ID: &str = "782ae96ea60f4cdf986a766049607005"; | |||
const REDIRECT_URI: &str = "http://127.0.0.1:8898/login"; | |||
const SPOTIFY_CLIENT_ID: &str = "65b708073fc0480ea92a077233ca87bd"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does the client id need to change? i guess we should eventually make this configurable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated my client to allow the expected redirect uris, if you want to revert that!
|
||
Button login_with_spotify_button { | ||
/* Translators: Log in button label */ | ||
label: _("Log in with Spotify"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the wording could probably be improved to make it clear its an external login, but I dont have any great suggestion just yet; probably need to review the whole ui of this dialog!
.url(); | ||
|
||
println!("Browse to: {}", auth_url); | ||
if let Err(err) = open::that(auth_url.to_string()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not super clear on the benefits, but I'd be interested in doing that with portals/ASPHD at some later time!
}?; | ||
trace!("Exchange {code:?} for access token"); | ||
|
||
// Do this sync in another thread because I am too stupid to make the async version work. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's absolutely fine that can be adressed later 😄
}; | ||
let refresh_token = match token.refresh_token() { | ||
Some(t) => t.secret().to_string(), | ||
_ => "".to_string(), // Spotify always provides a refresh token. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this trigger an error then?
|
||
let token_scopes: Vec<String> = match token.scopes() { | ||
Some(s) => s.iter().map(|s| s.to_string()).collect(), | ||
_ => scopes.into_iter().map(|s| s.to_string()).collect(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i guess its technically nullable but not really in practice, maybe it should be an error as well?
.map(|s| Scope::new(s.into())) | ||
.collect(); | ||
let (auth_url, _) = client | ||
.authorize_url(CsrfToken::new_random) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this token be validated somewhere down the line?
@@ -57,6 +57,12 @@ glib::wrapper! { | |||
pub struct ReleaseDetailsWindow(ObjectSubclass<imp::ReleaseDetailsWindow>) @extends gtk::Widget, libadwaita::Window, libadwaita::PreferencesWindow; | |||
} | |||
|
|||
impl Default for ReleaseDetailsWindow { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for taking care of clippy 😅
fixes #729, fixes #728 and fixes #726
works for me locally, I preserved the original login method, added a new one for login with spotify and fixed an issue that stopped tracks playing. I'm not massively familiar with this code (I pulled it yesterday because I wanted it to work on my pinephone) I'm happy to do a bit more to get this mergeable if needed but please bear in mind I may need a bit of guidance on what files to look at to solve issues