I already finished my django web app for my capstone project. This application use google drive API, my google drive will serves as the storage for the files that will be uploaded by the users. It is working fine on my local machine and successfully saved all the uploaded files in my google drive. But when I deployed my web application in pythonanywhere.com , if I upload a files in my web application, the google 0Auth screen is not appearing and my website and when I look into the server logs I found out that it is still pointing in my localhost.But I already change the redirect_uri and it doesn't contains localhost url. Here is the url i saw in server logs on pythonanywhere " https://accounts.google.com/o/oauth2/auth?client_id=445894491251-jrmvtgphqikehd6fe3qu6pn0fr7qbean.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2F&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&access_type=offline&response_type=code".
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from io import BytesIO
def upload_to_drive(request):
gauth = GoogleAuth()
gauth.LoadClientConfigFile('client_secrets.json')
gauth.access_type = 'online'
gauth.response_type = 'token'
drive = GoogleDrive(gauth)
file = request.FILES.get('submission')
with open(file.name, 'wb+') as destination:
for chunk in file.chunks():
destination.write(chunk)
file_drive = drive.CreateFile({'parents':[{`your text`'id':'10rAxM*****oeX5mL_CA******6vOPs'}],'title': file.name,'deletable': True})
file_drive.SetContentFile(file.name)
file_drive.GetPermissions
file_drive.Upload()
{"web":{"client_id":"4458491251-jrmvtgphqik***6pn0fr7qbean.apps.googleusercontent.com","project_id":"webrms-371102","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"GOCSPX-qojdjT5fXjEzrI5u","redirect_uris":["https://webrms.pythonanywhere.com/","https://webrms.pythonanywhere.com","https://webrms.pythonanywhere.com/task","https://webrms.pythonanywhere.com/task/","https://webrms.pythonanywhere.com/rms/login","https://webrms.pythonanywhere.com/rms","https://webrms.pythonanywhere.com/rms/","https://webrms.pythonanywhere.com/rms/task","https://webrms.pythonanywhere.com/rms/submission","https://webrms.pythonanywhere.com/submission","http://localhost:8090/","https://webrms.pythonanywhere.com/uploadmanuscript/","https://webrms.pythonanywhere.com/assigntasklistdetails/"],"javascript_origins":["https://webrms.pythonanywhere.com"]}}
here is my django code and my auth code for uploading file into my google drive. It's working fine on my local machine and I did not expect that it won't work after I deployed it on pythonanywhere. I was expecting the google 0Auth screen to appear, but my website was just kept on loading and says "something went wrong".All the features in my web application is working fine, except the uploading of files into my google drive storage.
by the way My Project in console.cloud.google.com was not yet published, is it possible to be the reason why my 0auth screen not appearing?
it is my first time to use google drive API and I really needs some help for my capstone projects this will be presented within this week.I humbly ask for your help, Thank you in advance.