Kindly review my basic Python script for accessing a Google spreadsheet stored in my Gmail Google Drive using my Gmail account. Unfortunately, I encountered an error. I would appreciate it if you could take a look at my code and the error message, and provide me with some guidance on how to access my Google spreadsheet using Python.
import pandas as pd
#Create a public URL
#https://docs.google.com/spreadsheets/d/0Ak1ecr7i0wotdGJmTURJRnZLYlV3M2daNTRubTdwTXc/edit?usp=sharing
#get spreadsheets key from url
#gsheetkey = "0Ak1ecr7i0wotdGJmTURJRnZLYlV3M2daNTRubTdwTXc"
#sheet name
sheet_name = 'data'
url=f'https://docs.google.com/spreadsheet/ccc?key={gsheetkey}&output=xlsx'
df = pd.read_excel(url,sheet_name=sheet_name)
print(df)
this is error
File "C:UsersAliAppDataLocalProgramsPythonPython312Liburllibrequest.py", line 639, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 401: Unauthorized
PS C:mainfolmfatt>