mirror of
https://github.com/librespot-org/librespot.git
synced 2026-04-27 08:15:50 +03:00
[PR #1309] [MERGED] Credentials with access token (oauth) #1333
Labels
No labels
A-Alsa
SpotifyAPI
Tokio 1.0
audio
bug
can't reproduce
compilation
dependencies
duplicate
enhancement
good first issue
help wanted
high priority
imported
imported
invalid
new api
pull-request
question
reverse engineering
wiki
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/librespot#1333
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/librespot-org/librespot/pull/1309
Author: @kingosticks
Created: 8/6/2024
Status: ✅ Merged
Merged: 9/13/2024
Merged by: @roderickvd
Base:
dev← Head:credentials_with_access_token📝 Commits (10+)
7a45614core: Create credentials from access token4956da9core: Credentials.username is optional.eeec818core: store auth data within sessionee7ba28oauth: obtain Spotify access token via OAuth260fae8fbin: New --token arg for using Spotify access tokenfe4d36boauth: break-out code parsing65a2526Updated token example70e2e5foauth: Update crate documentation2354d77ouath: error handling, pass scopes as param, redirect_port is Optione5f4e68oauth: Return type📊 Changes
17 files changed (+629 additions, -88 deletions)
View changed files
📝
CHANGELOG.md(+3 -0)📝
Cargo.toml(+4 -0)📝
core/Cargo.toml(+4 -0)📝
core/src/authentication.rs(+15 -7)📝
core/src/connection/mod.rs(+8 -5)📝
core/src/error.rs(+21 -0)📝
core/src/session.rs(+61 -15)📝
examples/get_token.rs(+24 -13)📝
examples/play.rs(+4 -4)📝
examples/play_connect.rs(+4 -4)📝
examples/playlist_tracks.rs(+4 -4)➕
oauth/Cargo.toml(+18 -0)➕
oauth/examples/oauth.rs(+32 -0)➕
oauth/src/lib.rs(+287 -0)📝
publish.sh(+1 -1)📝
src/lib.rs(+1 -0)📝
src/main.rs(+138 -35)📄 Description
I don't know if this oauth stuff really belongs in core, it doesn't feel quite right there so I added a new module. That new module could be useful standalone so it makes sense. If someone wants to take this and do something else that is fine by me.
This also leaves the token stuff a bit messy. We now provide two ways to get an access token:
session.token_provider().get_token("your,scopes")using keymaster (Mercury)session.spclient().auth_token()using login5 (HTTP)Both methods work (for session auth and playback) when you authenticate your session using a password or stored credentials. However, method 1 doesn't work when you authenticate your session using a spotify token (obtained using either method).
I think we want to get rid of this annoying pitfall. We could:
a) Get rid of method 1 altogether
b) Method 1 use method 2 under the hood
c) Change session authentication so when stored-creds are not used, it auths to obtain them and then re-auths using them.
Fixes #1308
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.