mirror of
https://github.com/librespot-org/librespot.git
synced 2026-04-27 00:05:55 +03:00
[PR #1462] [MERGED] OAuth process made by a struct, allowing customization options. #1405
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#1405
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/1462
Author: @SharliBeicon
Created: 1/31/2025
Status: ✅ Merged
Merged: 2/18/2025
Merged by: @photovoltex
Base:
dev← Head:dev📝 Commits (10+)
8d1a932get refresh token. Optional auth url browser openingaf0bdadchangelog3145ad9access token accepts custom message48d5c08docs updatedb9c7512CustomParams renamedea8d7f6OAuthToken can be clonedd34560ebuilder pattern on token managementa7852a5Merge branch 'librespot-org:dev' into devca9640achangelog5ee3376Merge branch 'dev' of github.com:SharliBeicon/librespot into dev📊 Changes
8 files changed (+474 additions, -56 deletions)
View changed files
📝
CHANGELOG.md(+22 -1)📝
Cargo.lock(+38 -0)📝
oauth/Cargo.toml(+2 -0)➖
oauth/examples/oauth.rs(+0 -32)➕
oauth/examples/oauth_async.rs(+65 -0)➕
oauth/examples/oauth_sync.rs(+64 -0)📝
oauth/src/lib.rs(+269 -14)📝
src/main.rs(+14 -9)📄 Description
Hello!
I'm currently working on a side project using this library. While working on it, I felt the need to open the auth URL automatically and customize the message returned by the socket. I added this functionality in my own fork, but I thought you might find it useful, so here's a Pull Request for it. If you don’t think it’s useful or it doesn’t meet your standards, feel free to close it!
I implemented it using a builder pattern that returns an OAuthClient with two functions:
get_access_token()andrefresh_token().The good old
get_access_token()is now marked for deprecation to allow for a smooth transition to the new structs. I also removed a weird overhead in the function, where it spawned a thread only to wait for its completion right after—so I figured it could just be removed.I’ve also modified the OAuth example so you can see how this implementation works.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.