I wrote a script to connect to a Google spreadsheet and load data into a postgresql database from it. I already created a service account and obtained the necessary credentials for it in a .json format,the problem is when I try to share the google sheet with my service account email, I receive an email saying:
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
that email is the exact same one I get in my .json key file. I have checked in other posts and generally the structure of the email that should be shared is something like this:
[email protected]
but mine is different, perhaps it has something to do with this? I followed the instructions on this link.
This is a copy of the .json key file:
{
"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"
}
I solved my issue:
Google has updated its service account detail format and also it's way of sharing Spreadsheets with service accounts so that they can be accessible from gspread.
I created then a service account with the new formating : [email protected] and set the exact same file google generates as a JSON to be read by my application:
login = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'], scope)
then shared without notifications the spreadsheet with my service account email (the same in the JSON file I just mentioned)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With