Add support for OAuth authentication strategy#931
Merged
devgianlu merged 4 commits intolibrespot-org:devfrom Oct 12, 2024
Merged
Add support for OAuth authentication strategy#931devgianlu merged 4 commits intolibrespot-org:devfrom
devgianlu merged 4 commits intolibrespot-org:devfrom
Conversation
Contributor
Author
|
Hey @devgianlu, could you have a look and do a quick review when you find a moment? |
Member
|
Thank you for the PR! |
|
Awesome - thx |
Contributor
Author
|
Thanks for review and merging @devgianlu! I wonder if you would mind creating a new release including this PR so that users can continue using the library without having to build themselves? |
Contributor
Author
|
Awesome, thanks a lot again! :) |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Spotify deprecated authentication with username and password and this authentication strategy no longer works in librespot-java resulting in
BadCredentialsexception (#921).This PR adds OAuth as new authentication strategy as replacement. It's basically a backport of the PR librespot-org/librespot#1309 from the related librespot project.
It adds all the OAuth logic as a new class in the lib module which is capable of providing LoginCredentials of type AUTHENTICATION_SPOTIFY_TOKEN by following the Authorization Code with PKCE Flow.
The session with token authentication can not be used with the keymaster which is why it does a reconnect with the ReusableAuthCredentials, same as in librespot.
To avoid having to authenticate with OAuth with every single run, it is intended to be used together with having storeCredentials enabled and it will default to use the stored credentials if they exist.
The OAuth class provides the full authentication flow with the
flowmethod including running a simple callback server suitable for a local terminal-based environments which can be used as reference and the player module and FileConfiguration is also adjusted to support it.The required steps for OAuth can also be done manually which makes it possible to integrate into non-terminal-based environments, such as Android in my case, in the following way:
Thanks a lot for the library! I know it is no longer actively maintained but I hope we can keep it working :)
Fixes #921