0

enter image description here 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

2
  • Does this answer your question? How do I access (read, write) Google Sheets spreadsheets with Python? Commented Aug 3, 2023 at 10:18
  • @Daviid Thanks for your answer, But in Flask API I have got auth_code, sheet_url, and sheet_name from the front end so how to create credentials using google auth_code or google refresh token? Commented Aug 3, 2023 at 14:35

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

2 Comments

can you provide me the code step by step?
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.