Understanding Google API (run_flow Method) Arguments

Asked 2 years ago, Updated 2 years ago, 361 views

Using the following site as a reference, I have created a code (sutra-copying, re-burning) to upload videos to YouTube.
The reference code is for OAuth authentication (run_flow method), passing argparser args, but
Could you tell me why I need to hand over the args?
(What is this args used for?)

Upload a video using YouTubeAPI

Intent Questions

I am considering making it into a module, and I thought it would be difficult to use the modules that require args.
Also, calling without args for the run_flow method argument seemed to work correctly.
Thank you for your cooperation.

 from oauth2 client.client import flow_from_clientsecrets
from oauth2client.tools import argparser, run_flow
from oauth2 client.file import Storage

flow = flow_from_clientsecrets(
    'client_secret_XXXXXXXX.apps.googleusercontent.com.json', #← File name hidden
    scope='https://www.googleapis.com/auth/youtube.upload',
    message = 'WARNING: Please configure OAuth 2.0'
)

if__name__=='__main__':
    storage=Storage('test-oauth2.json')
    args = argparser.parse_args()
    credentials = run_flow(flow, storage, args)# ← How does the third argument of this run_flow method affect?
    print (credentials)

python python3 google-api youtube-data-api

2022-09-30 22:02

1 Answers

Thank you for your comment.I can read it little by little.

Three factors appear to be utilized:
It seems that it is valid when you have your own site, so
I was able to decide if I could skip it once.

If you need to pass these parameters in the future,
Let's find out how to create args objects pseudonymously just before the run_flow method.

  • --auth_host_name (str, default:localhost)
    Hostname to use when running the local web server to handle redirects during OAuth authentication.

  • --auth_host_port (int, default: [8080, 8090])
    The port used to run the local web server to handle redirects during OAuth authentication.
    Repeat this option to specify a list of values.

  • -[no]auth_local_webserver (bool,default:True)
    Run the local web server to process the redirect during OAuth authentication.

--auth_host_name (str, default:localhost)
Hostname to use when running the local web server to handle redirects during OAuth authentication.

--auth_host_port (int, default: [8080, 8090])
The port used to run the local web server to handle redirects during OAuth authentication.
Repeat this option to specify a list of values.

-[no]auth_local_webserver (bool,default:True)
Run the local web server to process the redirect during OAuth authentication.


2022-09-30 22:02

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.