1

我编写了一个脚本来连接到Google电子表格,并从中将数据加载到postgresql数据库中。 我已经创建了一个服务帐户,并在以.json格式获得必要的凭证吧,问题是,当我试图共享谷歌片与我的服务帐户的电子邮件,我收到一封电子邮件,说:与服务帐户电子邮件共享Google工作表

Delivery to the following recipient failed permanently:

[email protected] 

Technical details of permanent failure: DNS Error: Address resolution of geometric-shine-118101.iam.gserviceaccount.com. failed: Domain name not found

该电子邮件与我在.json密钥文件中得到的完全一样。 我在其他职位已经确认并普遍认为应该共享电子邮件的结构是这样的:

[email protected] 

,但我的是不同的,或许它有事情做这件事? 我按照link的说明操作。

这是上传.json密钥文件的副本:

{ 
    "type": "service_account", 
    "project_id": "geometric-shine-118101", 
    "private_key_id": "xxx", 
    "private_key": "-----BEGIN PRIVATE KEY-----\nxxx\n-----END PRIVATE KEY-----\n", 
    "client_email": "[email protected]", 
    "client_id": "117076930343404252458", 
    "auth_uri": "https://accounts.google.com/o/oauth2/auth", 
    "token_uri": "https://accounts.google.com/o/oauth2/token", 
    "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", 
    "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/dataload%40geometric-shine-118101.iam.gserviceaccount.com" 
} 
+0

做您发送电子邮件的地址,它是否工作正常。我注意到它说DNS错误,所以看起来像地址是无效的。 – eddyparkinson

+0

但他是我的.json密钥文件中的地址。我编辑我的问题添加实际的文件。 – johan855

+1

这说明你的电子邮件格式是正确的。 http://stackoverflow.com/questions/34340150/which-email-to-use-in-google-service-account-api – eddyparkinson

回答

1

我解决我的问题:

谷歌已经更新了其服务帐户详细资料格式,也它的共享与服务帐户,以电子表格的方式他们可以从gspread访问。

然后我创建了一个服务帐户与新格式化:[email protected]并设置完全相同的文件谷歌产生的JSON通过我的应用程序可以读取:

login = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'], scope) 

然后在不通知的共享与我的服务帐户的电子邮件的电子表格(在JSON文件的同一我刚才提到的)

相关问题