google-api - 无法在多个 Airflow GCP 连接范围上上传到 Google Drive
问题描述
我正在构建一个 DAG,最后会使用 Airflow 的GoogleDriveHook
. 由于这是使用服务帐户执行的,因此我使用我的电子邮件作为delegate_to
参数,并预先启用了域范围的委派。电子邮件的范围是https://www.googleapis.com/auth/drive.file
。
如果连接的范围只是这样,DAG 会运行得很好,但是,由于我对使用其他 GCP 服务的其他 DAG 使用相同的 Airflow 连接,因此我必须为上述连接使用多个范围。
出于某种原因,它会在多个范围上的上传过程中失败,并喷出:
google.auth.exceptions.RefreshError: ('unauthorized_client: Client is unauthorized to retrieve access tokens using this method, or client not authorized for any of the scopes requested.', '{\n "error": "unauthorized_client",\n "error_description": "Client is unauthorized to retrieve access tokens using this method, or client not authorized for any of the scopes requested."\n}')
尽管拥有多个 Airflow 连接并不是什么大问题,但我想此时我只是好奇为什么会发生这种情况(Airflow 1.10.9)?
解决方案
我使用我的电子邮件作为 delegate_to 参数
- 您是否使用了 gsuite 域电子邮件?
- 您是否在 GSuite 中设置了域范围的委派?
委托仅适用于 Gsuite 域电子邮件。
如果您希望服务帐户能够访问您的个人非 g 套件 google 帐户。然后,您将需要在您的角色驱动器帐户上共享一个目录,并通过与其他用户共享目录来授予服务帐户对该目录的访问权限,就像您对任何其他用户一样。
上传文件后,它们将归服务帐户所有,您需要确保为该文件插入权限,以便您的个人帐户可以访问这些文件。
推荐阅读
- r - How can I export plots within a list in R?
- web-scraping - 刮擦属性。BeautifulSoup 锚点内的文本
- flutter - 在 initState Flutter 中获取 await 未来数据给出空值
- c# - 在 C# 中设置下拉列表的默认值
- c++ - constexpr 函数中的静态 constexpr 变量
- r - 如何比较两个 R 数据框以找到缺失的因子级别?
- c# - 上传时验证 GPX 文件
- assembly - PWM on a PIC18 using CCP4
- google-maps-api-3 - Google Maps API Clusterer 标记问题
- reactjs - React BrowserRouter 只加载 NavBar