10

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:

 dataload@geometric-shine-118101.iam.gserviceaccount.com

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:

project_name@developer.gserviceaccount.com

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": "dataload@geometric-shine-118101.iam.gserviceaccount.com",
  "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"
}
johan855
  • 1,578
  • 4
  • 26
  • 51
  • did you send an email to the address, did it work ok. I note it says DNS error, so looks like the address is invalid. – eddyparkinson Jan 09 '16 at 06:15
  • But his is the address inside my .json key file. I edited my uestion adding the actual file. – johan855 Jan 09 '16 at 13:51
  • 1
    This says the email format you have is right. http://stackoverflow.com/questions/34340150/which-email-to-use-in-google-service-account-api – eddyparkinson Jan 11 '16 at 00:13

1 Answers1

11

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 : dataload@geometric-shine-118101.iam.gserviceaccount.com 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)

johan855
  • 1,578
  • 4
  • 26
  • 51
  • SignedJwtAssertionCredentials has been removed https://github.com/googleapis/oauth2client/issues/401 – Sylvain Oct 29 '19 at 07:22