Oauth2-Error 400: redirect_uri_mismatch Django Application Drive API

Я хочу создать веб-приложение для загрузки и выгрузки файлов с Google Drive.Но "Ошибка 400: redirect_uri_mismatch" эта ошибка возникает, когда я работаю с Google Drive API. Я следовал Python Quickstart. Я пробовал это много раз, но не смог решить проблему. Я буду рад, если кто-нибудь поможет мне немного.

#quickstart.py

from __future__ import print_function
import os.path
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
from google.oauth2.credentials import Credentials
SCOPES = ['https://www.googleapis.com/auth/drive']

# If modifying these scopes, delete the file token.json.

"""Shows basic usage of the Drive v3 API.
Prints the names and ids of the first 10 files the user has access to.
"""
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(
            'client_secret_739947871599-3gcc50dnshrspe5g51cvunuar2u9efks.apps.googleusercontent.com.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('drive', 'v3', credentials=creds)

# Call the Drive v3 API
results = service.files().list(
    pageSize=10, fields="nextPageToken, files(id, name)").execute()
items = results.get('files', [])

if not items:
    print('No files found.')
else:
    print('Files:')
    for item in items:
        print(u'{0} ({1})'.format(item['name'], item['id']))

if __name__ == '__main__':
    main()

#views.py

from django.shortcuts import render
from .quickstart import *

def Home(request):


return render(request,'home.html')

def reHome(request):

   main()

return render(request,'yes.html')

#urls.py

from django.urls import path
from .import views
from django.contrib.auth.views import PasswordResetView,PasswordResetDoneView,PasswordResetCompleteView,PasswordResetConfirmView

urlpatterns = [
path('', views.Home, name='home'),
path('Login/', views.reHome, name='yes'),

]

#Авторизованное перенаправление

enter image description here

#error Error photo

Вернуться на верх