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

Custom OAuth token file path #120

Merged
merged 3 commits into from
Jul 19, 2024
Merged

Custom OAuth token file path #120

merged 3 commits into from
Jul 19, 2024

Conversation

potykion
Copy link
Contributor

@potykion potykion commented Jul 19, 2024

When using pytubefix.__main__.YouTube options use_oauth=True, allow_oauth_cache=True inner class pytubefix.innertube.InnerTube reads _token_file from fixed location which is pytube package location:

_cache_dir = pathlib.Path(__file__).parent.resolve() / '__cache__'
_token_file = os.path.join(_cache_dir, 'tokens.json')

This approach is not flexible and not approachable when using pytube in a cloud environments where you cant mannually obtain token by passing google authorization (this is related to #119).

This PR makes field token_file customizable so now you can obtain token once, save it and use it in cloud like so:

YouTube(
    "https://www.youtube.com/watch?v=K4TOrB7at0Y",
    use_oauth=True,
    allow_oauth_cache=True,
    token_file=BASE_DIR / "__cache__" / "tokens.json",
)

@JuanBindez JuanBindez changed the base branch from main to OAuth July 19, 2024 15:34
@JuanBindez JuanBindez merged commit ac0beb3 into JuanBindez:OAuth Jul 19, 2024
JuanBindez added a commit that referenced this pull request Jul 20, 2024
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