简体   繁体   English

从命令行使用令牌授权

[英]Authorization From Command Line Using Token

I can get authorization from browser,I use example from site and it's working. 我可以从浏览器获得授权,我可以从网站使用示例,并且可以正常工作。

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()))

But I want use it on remote server, after executing above code it show message that I can use "command-line parameter" but I don't know how to use it? 但是我想在远程服务器上使用它,执行上面的代码后,它显示消息我可以使用“命令行参数”,但是我不知道如何使用它?

I use example from this page: Google Developers 我使用以下页面中的示例: Google Developers

The command line utility outputs: 命令行实用程序输出:

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: #######

Run the command line utility with the --noauth_local_webserver flag. 使用--noauth_local_webserver标志运行命令行实用程序。

python get_oauth2_token.py --noauth_local_webserver

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM