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

Rework the auth flow to use google_oauth library and remove all my shitty code #17

Open
bastienboutonnet opened this issue Jan 19, 2022 · 0 comments

Comments

@bastienboutonnet
Copy link
Owner

https://google-auth-oauthlib.readthedocs.io/en/latest/
https://discord.com/channels/616562372945117184/726494914388688953/933454423219384370

# -*- coding: utf-8 -*-

# Sample Python code for youtube.liveBroadcasts.list
# See instructions for running these code samples locally:
# https://developers.google.com/explorer-help/guides/code_samples#python

import os

import google_auth_oauthlib.flow
import googleapiclient.discovery
import googleapiclient.errors

scopes = ["https://www.googleapis.com/auth/youtube.readonly"]

def main():
    # Disable OAuthlib's HTTPS verification when running locally.
    # *DO NOT* leave this option enabled in production.
    os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1"

    api_service_name = "youtube"
    api_version = "v3"
    client_secrets_file = "YOUR_CLIENT_SECRET_FILE.json"

    # Get credentials and create an API client
    flow = google_auth_oauthlib.flow.InstalledAppFlow.from_client_secrets_file(
        client_secrets_file, scopes)
    credentials = flow.run_console()
    youtube = googleapiclient.discovery.build(
        api_service_name, api_version, credentials=credentials)

    request = youtube.liveBroadcasts().list(
        part="snippet",
        broadcastStatus="active"
    )
    response = request.execute()

    print(response)

if __name__ == "__main__":
    main()

from: https://developers.google.com/youtube/v3/live/docs/liveBroadcasts/list?apix_params=%7B%22part%22%3A%5B%22snippet%22%5D%2C%22broadcastStatus%22%3A%22active%22%7D

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

No branches or pull requests

1 participant