Python 使用令牌从命令行进行授权

Python 使用令牌从命令行进行授权,python,google-drive-api,Python,Google Drive Api,我可以从浏览器中获得授权,我使用了来自网站的示例,它正在工作 SCOPES = 'https://www.googleapis.com/auth/drive' store = file.Storage('storage.json') creds = store.get() if not creds or creds.invalid: flow = client.flow_from_clientsecrets('client_id.json', SCOPES) creds = to

我可以从浏览器中获得授权,我使用了来自网站的示例,它正在工作

SCOPES = 'https://www.googleapis.com/auth/drive'
store = file.Storage('storage.json')
creds = store.get()
if not creds or creds.invalid:
    flow = client.flow_from_clientsecrets('client_id.json', SCOPES)
    creds = tools.run_flow(flow, store)
DRIVE = discovery.build('drive', 'v2', http=creds.authorize(Http()))
但我想在远程服务器上使用它,在执行上述代码后,它会显示一条消息,我可以使用“命令行参数”,但我不知道如何使用它


我使用此页面中的示例:

命令行实用程序输出:

Your browser has been opened to visit:

  https://accounts.google.com/o/oauth2/auth?scope=#########

If your browser is on a different machine then exit and re-run this application with the command-line parameter

--noauth_local_webserver

Authentication successful.
access_token: #######
使用--noauth_local_webserver标志运行命令行实用程序

python get_oauth2_token.py --noauth_local_webserver

请添加对您正在使用的文档的引用。我编辑了我的帖子。文档说:示例将尝试在默认浏览器中打开一个新窗口或选项卡。如果失败,请从控制台复制URL并在浏览器中手动打开。您可以将命令行实用程序的响应粘贴到此处(如果有,请清理url)?“如果您的浏览器位于其他计算机上,请退出并使用命令行参数重新运行此应用程序”我不明白如何使用命令行参数重新运行程序