Mar*_*res 1 authentication google-bigquery google-colaboratory
我长期使用 Colab 的 BigQuery,自 2020 年以来,我的帐户已加入 Google 的增强安全计划。直到昨天我还没有遇到任何身份验证问题
from google.colab import auth
auth.authenticate_user()
Run Code Online (Sandbox Code Playgroud)
但现在我收到了 400 错误。以下是它提供的详细信息:
access_type: offline
login_hint: (email)
response_type: none gsession
redirect_uri: https://colab.research.google.com/tun/m/auth-user-ephem
state: {"token":"(token)","endpoint":"(endpoint)","scopes":["openid","https://www.googleapis.com/auth/userinfo.email","https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/drive"]}
hd: (domain)
prompt: consent
client_id: (client_id)
scope: openid https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/drive
Run Code Online (Sandbox Code Playgroud)
我的问题: auth 上是否有允许进行身份验证的配置?
我也遇到过这个问题。Google 似乎已经更改了身份验证程序,以便您(或您的组织)必须将 colaboratory 添加到有权访问您帐户的应用程序列表中。
但是,还有一种方法可以恢复到无需任何特殊权限即可工作的旧身份验证行为:
import os
os.environ['USE_AUTH_EPHEM'] = '0'
from google.colab import auth
auth.authenticate_user()
Run Code Online (Sandbox Code Playgroud)
如果您查看该函数的源代码authenticate_user(),您可以看到它读取USE_AUTH_EPHEM环境变量来决定是使用旧的还是新的身份验证流程。
更新:
另一种(可能更适合未来)身份验证方法是在 Colab 中运行以下行。
!gcloud auth login --no-browser --update-adc
Run Code Online (Sandbox Code Playgroud)
这要求您在本地计算机上安装Google Cloud CLI ,然后只需按照说明操作即可。如果一切顺利,您将能够从 Colab 内访问 BigQuery,而无需致电auth.authenticate_user()。
| 归档时间: |
|
| 查看次数: |
2080 次 |
| 最近记录: |