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

I want Help for Google colab #3

Open
Woomer opened this issue Dec 16, 2023 · 0 comments
Open

I want Help for Google colab #3

Woomer opened this issue Dec 16, 2023 · 0 comments

Comments

@Woomer
Copy link

Woomer commented Dec 16, 2023

Hey I see you look very experienced in Google colab

I found an error using Google colab for some of my small projects
I didn't find any solution in any community like stack overflow,and other community

So I get you

The code is

import os
import google_auth_oauthlib.flow
import googleapiclient.discovery

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

def main():
os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1"

api_service_name = "youtube"
api_version = "v3"
client_secrets_file = "/content/credentials.json"

# Get credentials and create an API client
flow = google_auth_oauthlib.flow.InstalledAppFlow.from_client_secrets_file(
    client_secrets_file, scopes,redirect_uri="http://localhost:8800/")

authorization_url, _ = flow.authorization_url()

print(f"Please go to this URL to authorize: {authorization_url}")
authorization_response = input("Paste the authorization code here: ")

flow.fetch_token(
    "https://accounts.google.com/o/oauth2/token",
    authorization_response=authorization_response
)

youtube = googleapiclient.discovery.build(
    api_service_name, api_version, credentials=flow.credentials)

request = youtube.channels().list(
    part="snippet,contentDetails,statistics",
    mine=True
)
response = request.execute()

print(response)

if name == "main":
main()

When opening the link and selecting my account after that it showing me

This site can’t be reached
localhost refused to connect.
Try:

Checking the connection
ERR_CONNECTION_REFUSED

(I dont want to use vs code( it works there ))

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