Google cloud platform 使用Colaboratory永久允许Google Cloud SDK访问您的Google帐户
将Google Colaboratory与Google Cloud一起使用时,必须对自己进行身份验证:Google cloud platform 使用Colaboratory永久允许Google Cloud SDK访问您的Google帐户,google-cloud-platform,google-colaboratory,google-workspace,google-cloud-sdk,Google Cloud Platform,Google Colaboratory,Google Workspace,Google Cloud Sdk,将Google Colaboratory与Google Cloud一起使用时,必须对自己进行身份验证: from google.colab import auth auth.authenticate_user() print('Authenticated') 运行该单元格的结果是: Go to the following link in your browser: https://accounts.google.com/o/oauth2/...... Enter verificat
from google.colab import auth
auth.authenticate_user()
print('Authenticated')
运行该单元格的结果是:
Go to the following link in your browser:
https://accounts.google.com/o/oauth2/......
Enter verification code:
目前,每当我启动一个新笔记本时,我必须授予它访问权限并输入一个新密码,这让我觉得我做错了什么
有没有办法永久允许Google Cloud SDK访问我的Google帐户?您可以将凭据保存为API密钥的形式,然后在磁盘上写入文件。这仍然需要在每个笔记本中运行一个单元格来进行身份验证,但至少您不必每次都单击身份验证流 有关为服务帐户创建API密钥的信息,请参阅 然后,在笔记本上写下如下内容:
import os
storage_auth_info = r"""YOUR API KEY HERE"""
with open('/tmp/storage_auth_info.json', 'w') as f:
f.write(storage_auth_info)
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = '/tmp/storage_auth_info.json'
这将允许任何访问您的笔记本的人使用保存的凭据,因此谨慎使用,例如,只考虑向服务帐户只读访问您的数据。