[PR #1462] [MERGED] OAuth process made by a struct, allowing customization options. #1405

Closed
opened 2026-02-27 20:02:20 +03:00 by kerem · 0 comments
Owner

📋 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: devHead: dev


📝 Commits (10+)

  • 8d1a932 get refresh token. Optional auth url browser opening
  • af0bdad changelog
  • 3145ad9 access token accepts custom message
  • 48d5c08 docs updated
  • b9c7512 CustomParams renamed
  • ea8d7f6 OAuthToken can be cloned
  • d34560e builder pattern on token management
  • a7852a5 Merge branch 'librespot-org:dev' into dev
  • ca9640a changelog
  • 5ee3376 Merge 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() and refresh_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.

## 📋 Pull Request Information **Original PR:** https://github.com/librespot-org/librespot/pull/1462 **Author:** [@SharliBeicon](https://github.com/SharliBeicon) **Created:** 1/31/2025 **Status:** ✅ Merged **Merged:** 2/18/2025 **Merged by:** [@photovoltex](https://github.com/photovoltex) **Base:** `dev` ← **Head:** `dev` --- ### 📝 Commits (10+) - [`8d1a932`](https://github.com/librespot-org/librespot/commit/8d1a93288e088346955f2f0ef7fc97683c97da62) get refresh token. Optional auth url browser opening - [`af0bdad`](https://github.com/librespot-org/librespot/commit/af0bdadac673f34883d7b4e324d3e7b956e21074) changelog - [`3145ad9`](https://github.com/librespot-org/librespot/commit/3145ad91f8fb4879f695c84f2e51803249fd75cf) access token accepts custom message - [`48d5c08`](https://github.com/librespot-org/librespot/commit/48d5c08fc12ff3d77123179912769ec685a440fd) docs updated - [`b9c7512`](https://github.com/librespot-org/librespot/commit/b9c7512522eb3873580f001312f412f3886e8cb5) CustomParams renamed - [`ea8d7f6`](https://github.com/librespot-org/librespot/commit/ea8d7f67a110fd3c71a3d57f399ab31b533be2ef) OAuthToken can be cloned - [`d34560e`](https://github.com/librespot-org/librespot/commit/d34560e58cf357743c442d2eacac79d2c8d0f638) builder pattern on token management - [`a7852a5`](https://github.com/librespot-org/librespot/commit/a7852a5af535bc27d2ec93c7d9e447d524b68a99) Merge branch 'librespot-org:dev' into dev - [`ca9640a`](https://github.com/librespot-org/librespot/commit/ca9640ad7df126943f1324be471686f51c8ffa3b) changelog - [`5ee3376`](https://github.com/librespot-org/librespot/commit/5ee33761fae74f32978a27ebdf220acd3c349251) Merge branch 'dev' of github.com:SharliBeicon/librespot into dev ### 📊 Changes **8 files changed** (+474 additions, -56 deletions) <details> <summary>View changed files</summary> 📝 `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) </details> ### 📄 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()` and `refresh_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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 20:02:20 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/librespot#1405
No description provided.