Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional parameters for OAuth client ID and secret to setup #688

Merged
merged 10 commits into from
Dec 17, 2024

Conversation

fischcode
Copy link
Contributor

Use your own Google API client ID and client secret in setup by calling ytmusicapi oauth --client_id <your Google API client ID> --client_secret <your Google API client secret> to avoid HTTP 400: Bad Request errors (issue #679 )
See developers.google.com/youtube/registering_an_application for instructions on how to create your own youtube OAuth credentials.

Use your own Google API client ID and client secret in setup by calling
ytmusicapi oauth --client_id <your Google API client ID> --client_secret <your Google API client secret> to avoid HTTP 400: Bad Request errors
Copy link
Owner

@sigma67 sigma67 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for for figuring this out and submitting the PR. However, there are still some more improvements needed:

  • The argparse args you added apply to both setup types, although they don't matter for the browser option. This will lead to a misleading CLI (i.e. try running ytmusicapi browser --help). They should only apply to the oauth option. Since the interface is interactive anyway you could also circumvent this by interactively asking for TV auth (deprecated) or client id/secret (recommended) - then request all the info via input(). Both solutions are valid imo.
  • Deprecate the current TV oauth docs and include info on how it should be done currently. This would mean adding guidance on how to correctly create the ID/Secret via Google Cloud. Could be done in a separate PR

@sigma67
Copy link
Owner

sigma67 commented Dec 15, 2024

Which type of OAuth 2.0 client/id secret are you creating? "TV and limited input" or something else? I'm still getting 401 unauthorized here

nevermind, it does seem to work with that configuration

- Add subparsers for parameters for oauth and browser tokens
- Add help options
- Add a check for presence of both client_id and client_secret if oauth is chosen.
@fischcode
Copy link
Contributor Author

Hi
I added subparsers for oauth / browser and validation if oauth is chosen as requested. Hope this meets your expectations.
However, I am reluctant to write instructions on how to create API keys at this time, as I haven't yet figured out the minimum scope required for all ytmusicapi features to work and Google appears to be in the process of changing the UI for key creation.
Here is one page with instructions ("API Key Creation") that you might want to test and copy into the ytmusicapi documentation if successful: https://github.com/Kuschranada/plugin.video.youtube/wiki/Personal-API-Keys

Copy link

codecov bot commented Dec 17, 2024

Codecov Report

Attention: Patch coverage is 88.88889% with 2 lines in your changes missing coverage. Please review.

Project coverage is 94.88%. Comparing base (8f479b1) to head (2b86d17).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
ytmusicapi/setup.py 83.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #688      +/-   ##
==========================================
- Coverage   95.04%   94.88%   -0.17%     
==========================================
  Files          38       38              
  Lines        2282     2288       +6     
==========================================
+ Hits         2169     2171       +2     
- Misses        113      117       +4     
Flag Coverage Δ
unittests 94.88% <88.88%> (-0.17%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sigma67 sigma67 merged commit fe95f59 into sigma67:main Dec 17, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants