curl - Google Drive API:如何连接到“受限 API”?
问题描述
我正在尝试连接到 Google Drive V3 API:https ://www.googleapis.com/auth/drive 但根据 Google文档,此 API 访问是“受限的”。我想使用这个 API,因为这是唯一允许“查看、编辑、创建和删除所有Google Drive 文件”的 API。
然后,它说“如果您认为您的应用程序需要限制范围,请参阅请求限制范围验证和安全评估。”
之后,我确实尝试使用Whitelist connected apps中的 Step2 将我的应用程序列入白名单,但没有成功:
$ curl -d 'client_id=[$CLIENT_ID]' -d 'scope=https://www.googleapis.com/auth/drive' -d 'response_type=code' 'https://accounts.google.com/o/oauth2/device/code'
curl: (3) Illegal characters found in URL
欢迎任何建议。或者任何关于列出我所有文件的其他方法的建议也将受到欢迎。先感谢您。
解决方案
显然,它有效,但我使用了错误的 cURL 命令。正确的是:
curl ^
--data client_id=%CLIENT_ID% ^
--data client_secret=%CLIENT_SECRET% ^
--data code=%AUTH_CODE% ^
--data redirect_uri=urn:ietf:wg:oauth:2.0:oob ^
--data grant_type=authorization_code ^
https://www.googleapis.com/oauth2/v4/token
推荐阅读
- javascript - What is the best way to communicate and pass data between child polymer elements?
- python - python + sqlite 将变量插入 PRAGMA 语句
- laravel - 从自定义验证对象中检索参数
- ajax - 代码点火器验证-Ajax,错误:验证时功能工作->运行为真
- html - HTML - 按钮和输入
- python - 如何在 Eric6 中单独使用 Qt Designer 和 PyQt5 的离线文档?
- ruby-on-rails - Ruby on Rails - 权威宝石 - 未定义的方法
- c# - CORS 策略中不允许请求方法 POST
- ionic-framework - 离子闪屏在较旧的 android 上提供 ERR_CONNECTION_REFUSED
- c# - JSON到数据表忽略数组