OAuth Issue - Google Sheets REST API

Hi everyone! I'm trying to connect the Google Sheets API - using the Retool built-in Sheets resource has known issues.

I'm using OAUTH 2.0 but for some reason it's still giving me a 401 Invalid auth creds error.

Here's the resource config:


Here's the in-workflow resource config:

Here's the error I'm getting:

Hello @fish_hatchery2, Welcome Back Community Forum.

Use the Auth Token in the Header Authorization Key, generated via the Get Sheet Data URL.

image

You can see my actual access token in the image.

Use a URL like this to generate an access token:

https://accounts.google.com/o/oauth2/auth?client_id=YOUR_CLIENT_ID&redirect_uri=YOUR_REDIRECT_URI&response_type=code&scope=https://www.googleapis.com/auth/spreadsheets&access_type=offline&prompt=consent

Let me know if you need any help.

3 Likes

Hey @fish_hatchery2! Thanks again for joining office hours the other day. :slightly_smiling_face:

Seeing your setup here, I think I have a better understanding of what's going on. Generally speaking, the Google APIs don't support the client credentials grant type. You can implement a workaround similar to what @WidleStudioLLP described, but the caveat there is that your access_token will eventually expire. The best practice for server-to-server communication with Google APIs is to configure a service account.

Let me know if you have any questions about that!

1 Like