Forums

Using Google Drive API and G spreadsheet API in the same script

Hello, I tried to find my own threat but was not able to do so in all the ... I don't know how to call what is happening to your site. Courage!! Here is my code

And here is the Error message.

Traceback (most recent call last): File "C:/Users/user/Desktop/Python/Google spreadsheet/GspreadsheetApi1.py", line 20, in <module> credentials = ServiceAccountCredentials.from_json_keyfile_name('client_secrets.json', scope) # Your json file here File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\oauth2client\service_account.py", line 221, in from_json_keyfile_name return cls._from_parsed_json_keyfile(client_credentials, scopes, File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\oauth2client\service_account.py", line 171, in _from_parsed_json_keyfile raise ValueError('Unexpected credentials type', creds_type, ValueError: ('Unexpected credentials type', None, 'Expected', 'service_account')

can we use the same credential for the script??

Found the solution, ” just a guess, but what you have most likely created is "API Key" or "OAuth 2.0 client ID" json file, while what you need for gspread to work is "Service account key" json. Go back to the https://console.developers.google.com/apis/credentials and create new credentials and when selecting option, pick the last one - Service account key.” that's what I did. and it's working, ugly code but working.

Interesting! I'm glad to hear you worked it out eventually.