In that screenshot this is the front end, after Google login I have got auth_code in the backend flask API, now how to read restricted Google sheet data based on that user auth_code
Thanks In advance
In that screenshot this is the front end, after Google login I have got auth_code in the backend flask API, now how to read restricted Google sheet data based on that user auth_code
Thanks In advance
Here's a step-by-step guide on how to achieve this:
Set up a Google Cloud Platform (GCP) project:
Go to the Google Cloud Console (https://console.cloud.google.com/) and create a new project. Enable the Google Sheets API for your project. Create credentials (OAuth 2.0 client ID) for your application. Obtain the user's Auth code:
When the user wants to access their restricted data, direct them to a Google OAuth consent screen, where they'll log in and grant your application the necessary permissions. After granting permission, the user will be redirected to your application's redirect URL with the Auth code appended as a query parameter. Exchange the Auth code for an access token:
In your application, use the Auth code to request an access token by making a POST request to the Google OAuth token endpoint. The request should include your client ID, client secret, redirect URL, and the Auth code. Use the access token to read Google Sheet data:
Once you have obtained the access token, you can use it to authenticate your API requests to read the restricted Google Sheet data. Use the Google Sheets API to fetch the data from the Sheet. You'll need to specify the Sheet ID and the range of data you want to read.