Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

Is it possible to disable google-API authorization?

$
0
0

I am writing a simple python script that gets a YouTube video duration using google-API.This is the code I wrote:

# importsimport osimport google_auth_oauthlib.flowimport googleapiclient.discoveryimport googleapiclient.errorsimport aniso8601scopes = ["https://www.googleapis.com/auth/youtube.readonly"]# 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"# File name which has the credentials(API/OAuth)client_secrets_file = "MY_FILE_NAME.json"# Get credentials and create an API clientflow = 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.videos().list(    part="contentDetails",    id="CbxQWAFv7sA")response = request.execute()duration_in_iso_8601 = response['items'][0]['contentDetails']['duration']duration_in_seconds = aniso8601.parse_duration(duration_in_iso_8601).secondsprint(duration_in_seconds)

Now, everything works fine except the fact that every time I run the script I am asked to enter an authorization code:

Please visit this URL to authorize this application: https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=MY_ID.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fyoutube.readonly&state=i4RuG2QRXmef9t5MQUoOOqSXGhvMM5&prompt=consent&access_type=offlineEnter the authorization code: 

My goal is that eventually the script will be automated on different devices, so the above interrupts the flow. I wanted to know, Is there any way to disable this prompt? If not, is there any other way to implement this such that the authorization won't interfere the flow?Thanks a lot!


Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>