oauth-2.0 - 谷歌云函数 REST API 身份验证
问题描述
我想使用 Google 提供的以下 API:https ://cloud.google.com/functions/docs/reference/rest/
我向端点发出GET /v1/{name}/locations请求并收到 HTTP 401 错误。这意味着我没有设置身份验证。作为参考,这是我正在运行的代码:
import requests
def list(project_id):
endpoint = 'https://cloudfunctions.googleapis.com/v1/projects/'
endpoint += project_id
endpoint += '/locations'
r = requests.get(endpoint)
return r
链接的文档指出,我需要拥有以下两个 OAuth 范围之一:
https://www.googleapis.com/auth/cloudfunctions
https://www.googleapis.com/auth/cloud-platform
我如何获得这些范围?我已经下载了凭证文件并导出了此处文档中列出的环境变量。我目前没有在任何地方使用这些凭据,因为通过纯文本发送私钥似乎存在安全风险。
有人可以解释如何将此 401 身份验证错误转换为 200 成功(或任何其他错误)吗?
解决方案
推荐阅读
- css - 如何使 Ionic 4 ion-col 高度相同
- nativescript - NativeScript RadDataForm validateAndCommitAll 在 iOS 上不起作用
- java - 如何在代码行之间设置等待时间
- php - PDO SQLite 是否支持数学运算的 where 子句?
- python-3.x - 如何将 Python 3 与依赖于 Python 2 的标准 JModelica 结合起来?
- azure-active-directory - Microsoft 身份验证请求具有访问令牌的附加范围
- android - 如何在android的工具栏内添加开关?
- python - 如何将 csv 日期时间字符串保存到 Django 模型字段中
- pointers - 这种二叉树的实现可能会出现什么问题?
- ethereum - 如何在不使用元掩码的情况下切换帐户?