I have a JSON file from google spreadsheet (for reading the spreadsheet).
I'm trying to copy the JSON as a string to the script.
this is how I do it :
from oauth2client.service_account import ServiceAccountCredentials
import gspread
json_string ='''
{
"type": "service_account",
"project_id": "ID",
"private_key_id": "KEYID",
"private_key": "-----BEGIN PRIVATE KEY-----
......KEY HERE......
-----END PRIVATE KEY-----
",
"client_email": "EMAIL",
"client_id": "ID",
"auth_uri": "URI",
"token_uri": "URI",
"auth_provider_x509_cert_url": "URL",
"client_x509_cert_url": "CLINET"
}
'''
info = json.loads(json_string.replace("'",'"').replace('\r\n', '\\r\\n'), strict=False)
client = gspread.authorize(credentials)
sheet = client.open("Responses").sheet1
...
ERROR OUTPUT -
private_key_pkcs8_pem = json_data['_private_key_pkcs8_pem']
KeyError: '_private_key_pkcs8_pem'
Any suggestions for how to read the string as JSON credentials correctly?