[PR #488] [MERGED] Authentication refactor #618

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

📋 Pull Request Information

Original PR: https://github.com/sigma67/ytmusicapi/pull/488
Author: @jcbirdwell
Created: 12/17/2023
Status: Merged
Merged: 12/31/2023
Merged by: @sigma67

Base: masterHead: alt_auth


📝 Commits (10+)

  • e21492b oauth: add support for alternate oauth client
  • b9be59d get_album_browse_id: fix depreciated escape sequence error && add performance increase
  • b2c078d get_charts: fix index errors on authorized song chart missing
  • b60af9c add: set_album_save as a convenience/alias/findable method for album rate_playlist
  • 91949b5 fix: externalize library dependent or regional arguments to test.cfg
  • 6c94c80 add: integrate alt_oauth into YTMusic && add: token dict support for auth parameter
  • 742f584 unadd: set_album_save. unneeded duplicate to rate_playlist
  • 10241c7 fix: dataclass implementation of credentials
  • 9cb8c63 minor touch-up: rebuild the entire oauth system
  • 8dac2e5 fix: new token init

📊 Changes

17 files changed (+703 additions, -246 deletions)

View changed files

📝 tests/README.rst (+17 -3)
📝 tests/test.cfg.example (+15 -4)
📝 tests/test.py (+117 -41)
ytmusicapi/auth/headers.py (+0 -48)
ytmusicapi/auth/oauth.py (+0 -102)
ytmusicapi/auth/oauth/__init__.py (+5 -0)
ytmusicapi/auth/oauth/base.py (+134 -0)
ytmusicapi/auth/oauth/credentials.py (+123 -0)
ytmusicapi/auth/oauth/exceptions.py (+12 -0)
ytmusicapi/auth/oauth/models.py (+32 -0)
ytmusicapi/auth/oauth/refreshing.py (+91 -0)
ytmusicapi/auth/types.py (+25 -0)
📝 ytmusicapi/mixins/browsing.py (+2 -1)
📝 ytmusicapi/mixins/explore.py (+9 -5)
📝 ytmusicapi/mixins/uploads.py (+2 -1)
📝 ytmusicapi/setup.py (+16 -3)
📝 ytmusicapi/ytmusic.py (+103 -38)

📄 Description

This is the implementation of #487. It also fixes some issues I ran across while writing the tests for my proposed feature that were preventing a full pass. I can open issues for each or all together if needed, just let me know. Otherwise, they were:

  1. A test was throwing a depreciation warning stemming from a regex search in get_album_browse_id, I changed it to use a str.find slicer, which fixed the warning and made it a touch faster.
  2. It looks like the songs section of charts is no longer provided by YouTube (could be regional), which was producing an indexing error in get_charts when authenticated. I changed it to check that the results array had enough members before it inserted the songs key. This prevents the error without depreciating the feature should the section be added back on googles end.
  3. While prepping a YouTube music account library for the tests I couldn't find the method for saving albums, so I wrote one, only to find afterwards it was written in as a footnote of the rate_playlists method. I went ahead and committed it as an alias/convenience method for other idiots like myself that couldn't find the other. Ignore it if you want.
  4. I may have just been cluelessly butchering my test.py and test.cfg trying to get unitests up and running, but there were a few variables that seemed to be library or region dependent, which I externalized to the cfg so as to be more clearly customizable. If that was a bad call and the purpose of the tests went over my head, let me know so I can redo and rerun with the other variables.

🔄 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/sigma67/ytmusicapi/pull/488 **Author:** [@jcbirdwell](https://github.com/jcbirdwell) **Created:** 12/17/2023 **Status:** ✅ Merged **Merged:** 12/31/2023 **Merged by:** [@sigma67](https://github.com/sigma67) **Base:** `master` ← **Head:** `alt_auth` --- ### 📝 Commits (10+) - [`e21492b`](https://github.com/sigma67/ytmusicapi/commit/e21492b7d380a8ed006abf70c04583c661900f12) oauth: add support for alternate oauth client - [`b9be59d`](https://github.com/sigma67/ytmusicapi/commit/b9be59de50c93739ce8e979162c5ac96abb00ea3) get_album_browse_id: fix depreciated escape sequence error && add performance increase - [`b2c078d`](https://github.com/sigma67/ytmusicapi/commit/b2c078df636fd82548af8359cb0491cd23ccdccf) get_charts: fix index errors on authorized song chart missing - [`b60af9c`](https://github.com/sigma67/ytmusicapi/commit/b60af9cc25cc39f5f8759a63a323a658b5389d0c) add: set_album_save as a convenience/alias/findable method for album rate_playlist - [`91949b5`](https://github.com/sigma67/ytmusicapi/commit/91949b54031bd4d9c95ccca4ff31906a940bf1a7) fix: externalize library dependent or regional arguments to test.cfg - [`6c94c80`](https://github.com/sigma67/ytmusicapi/commit/6c94c80086a2eabd90177365dae309b8bb473af5) add: integrate alt_oauth into YTMusic && add: token dict support for auth parameter - [`742f584`](https://github.com/sigma67/ytmusicapi/commit/742f5842fa554e60e6b718780eca4d3577d38127) unadd: set_album_save. unneeded duplicate to rate_playlist - [`10241c7`](https://github.com/sigma67/ytmusicapi/commit/10241c7ee44090af30937e2a7a45aaf83f9bc4a4) fix: dataclass implementation of credentials - [`9cb8c63`](https://github.com/sigma67/ytmusicapi/commit/9cb8c63d99e5ad45d71e076d55a658fe2c5f040b) minor touch-up: rebuild the entire oauth system - [`8dac2e5`](https://github.com/sigma67/ytmusicapi/commit/8dac2e528f042203cbf63ecc94a51236808d6c4e) fix: new token init ### 📊 Changes **17 files changed** (+703 additions, -246 deletions) <details> <summary>View changed files</summary> 📝 `tests/README.rst` (+17 -3) 📝 `tests/test.cfg.example` (+15 -4) 📝 `tests/test.py` (+117 -41) ➖ `ytmusicapi/auth/headers.py` (+0 -48) ➖ `ytmusicapi/auth/oauth.py` (+0 -102) ➕ `ytmusicapi/auth/oauth/__init__.py` (+5 -0) ➕ `ytmusicapi/auth/oauth/base.py` (+134 -0) ➕ `ytmusicapi/auth/oauth/credentials.py` (+123 -0) ➕ `ytmusicapi/auth/oauth/exceptions.py` (+12 -0) ➕ `ytmusicapi/auth/oauth/models.py` (+32 -0) ➕ `ytmusicapi/auth/oauth/refreshing.py` (+91 -0) ➕ `ytmusicapi/auth/types.py` (+25 -0) 📝 `ytmusicapi/mixins/browsing.py` (+2 -1) 📝 `ytmusicapi/mixins/explore.py` (+9 -5) 📝 `ytmusicapi/mixins/uploads.py` (+2 -1) 📝 `ytmusicapi/setup.py` (+16 -3) 📝 `ytmusicapi/ytmusic.py` (+103 -38) </details> ### 📄 Description This is the implementation of #487. It also fixes some issues I ran across while writing the tests for my proposed feature that were preventing a full pass. I can open issues for each or all together if needed, just let me know. Otherwise, they were: 1. A test was throwing a depreciation warning stemming from a regex search in get_album_browse_id, I changed it to use a str.find slicer, which fixed the warning and made it a touch faster. 2. It looks like the songs section of charts is no longer provided by YouTube (could be regional), which was producing an indexing error in get_charts when authenticated. I changed it to check that the results array had enough members before it inserted the songs key. This prevents the error without depreciating the feature should the section be added back on googles end. 3. While prepping a YouTube music account library for the tests I couldn't find the method for saving albums, so I wrote one, only to find afterwards it was written in as a footnote of the rate_playlists method. I went ahead and committed it as an alias/convenience method for other idiots like myself that couldn't find the other. Ignore it if you want. 4. I may have just been cluelessly butchering my test.py and test.cfg trying to get unitests up and running, but there were a few variables that seemed to be library or region dependent, which I externalized to the cfg so as to be more clearly customizable. If that was a bad call and the purpose of the tests went over my head, let me know so I can redo and rerun with the other variables. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 23:01:43 +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/ytmusicapi#618
No description provided.