Django-React google calendar API redirect_uri_mismatch
my react is in http://localhost:3000 my django is in http://localhost:8000
im trying to get the info form my calendar, i found this code in link
`class Test(APIView):
def get(self, request):
"""Shows basic usage of the Google Calendar API.
Prints the start and name of the next 10 events on the user's calendar.
"""
SCOPES = ['https://www.googleapis.com/auth/calendar']
creds = None
# The file token.json stores the user's access and refresh tokens, and is
# created automatically when the authorization flow completes for the first
# time.
if os.path.exists("token.json"):
creds = Credentials.from_authorized_user_file("token.json", SCOPES)
# If there are no (valid) credentials available, let the user log in.
if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request())
else:
flow = InstalledAppFlow.from_client_secrets_file(
"notes/credentials.json", SCOPES
)
creds = flow.run_local_server(port=0)
# Save the credentials for the next run
with open("token.json", "w") as token:
token.write(creds.to_json())
service = build("calendar", "v3", credentials=creds)
# Call the Calendar API
now = datetime.utcnow().isoformat() + "Z" # 'Z' indicates UTC time
print("Getting the upcoming 10 events")
events_result = (
service.events()
.list(
calendarId="primary",
timeMin=now,
maxResults=10,
singleEvents=True,
orderBy="startTime",
)
.execute()
)
events = events_result.get("items", [])
if not events:
print("No upcoming events found.")
return JsonResponse({'message': 'No upcoming events found.'}, status=200)
# Prepare data to be returned
events_data = []
for event in events:
start = event["start"].get("dateTime", event["start"].get("date"))
events_data.append({"start": start, "summary": event["summary"]})
return JsonResponse({'events': events_data}, status=200)
`
but when i try to send the request using postman, i have an error
idk how to solve it. i have been reading and they tell me to add URLs to the Authorized JavaScript origins and the Authorized redirect URIs of the credential setting in the api, but nothing works. my end objective is to create event in the calendar, but im tyring to get them for now and it does not work.
