google 0Auth screen authentication not appearing after deploying my django web aplication in pythonanywhere - google-drive-api

google 0Auth screen
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.

Related

what client_secret.json file is it required for google drive files access

I am getting this error:
File "/usr/local/lib/python3.7/site-packages/pydrive/auth.py", line 388, in LoadClientConfigFile
raise InvalidConfigError('Invalid client secrets file %s' % error)
pydrive.settings.InvalidConfigError: Invalid client secrets file ('Error opening file', 'client_secrets.json', 'No such file or directory', 2)
all I want is to list files and folders using pydrive !
I tried creating credentials but On consent page its showing unverified status.
from the credential page under OAuth 2.0 Client IDs tab I downloaded created credentials and downloaded crediential file secret_json_[.....].json file
Looking into the documentation for pyDrive:
Click ‘Download JSON’ on the right side of Client ID to download client_secret_<really long ID>.json.
The downloaded file has all authentication information of your application. Rename the file to client_secrets.json and place it in your working directory.
So probably you are lacking the last step of renaming the file and placing it in the working directory.
I tried creating credentials but On consent page its showing unverified status.
This should not matter at all, unverified just means that you are trying to access sensitive scopes and until Google verifies your application there would be an extra screen indicating that it is a unverified apps. Is okay for personal/development use.

How to explore Google Endpoint API hosted over HTTP without generating google chrome files in my project folder?

I am testing my Google Endpoint API over localhost. And to test the api locally, I am following this command suggested from google- (https://developers.google.com/explorer-help/#hitting_local_api)
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --user-data-dir="C:\Users\Probhat\workspace\codesap" --unsafely-treat-insecure-origin-as-secure=http://localhost:8888
It is working fine. I can access the API's. But the main problem here is that the command itself generating some extra files in my project folder. And the files are very irritating while developing the project.
Earlier I can easily load the api's just clicking "Load Unsafe Scripts". It did not generate the chrome files. But this is not working now.
I want to know is there any way to test the API's in Chrome without generating those files?

Install firefox os apps available on Marketplace using App Manager

I am trying to install App using App Manager in Firefox OS device. But my problem is I am unable to push any of the apps which are published on MarketPlace. It show that
The webapp manifest isn't a valid JSON file: SyntaxError: JSON.parse:
unexpected character at line 1 column 1 of the JSON data at:
https://marketplace.firefox.com/app/pacman-canvas can't be opened
So can anyone suggest some way to push the app to my device using App Manager only?
It's pretty easy. On the Marketplace page (in Firefox desktop) open the marketplace page for the app. Then open Devtools and select the Debugger. In the debugger, break in file iframe-installer.html, on this line:
installPackage(e);
Now click the 'Free' button, the debugger will break on this line. In the console you now type:
e.data.data.product.manifest_url
This will give you a URL. If the URL is located at someone else's webserver (like Pacman), e.g. http://pacman.platzh1rsch.ch/pacman-canvas.webapp, you can (in the App Manager) click 'Add hosted app' and paste the URL. However you will need internet on the phone the first time you use the app (because its hosted app).
If the URL is a Mozilla URL (https://marketplace.firefox.com/app/etc.), you can open the link in your browser. Open the file. You now have a JSON file in which you need to look for the package_path key. F.e. for Recorder it's
"package_path": "https://marketplace.firefox.com/downloads/file/258677/recorder-1.1.zip"
You can now download this ZIP file, unzip it in a folder, and add the folder as a Packaged app.
For apps in the marketplace, you best solution for getting them on the phone is to just use the marketplace app. That said if you own the app in the marketplace you should be able to look at the manifest url of the app using the edit listing marketplace button. If this is a hosted app you can you use this manifest url in the add hosted app entry box within the app manager to add it and then push it to phone. On another note you can debug the system apps by using the procedure described here:
https://developer.mozilla.org/en-US/Firefox_OS/Using_the_App_Manager#Debugging_Certified_Apps

Open With from Chromebook file app doesn't work

I have a Google Drive app, which is registered as my default opener on Google Drive. This works perfectly fine when opening files using drive.google.com - When I open a file with my App, the app gets given permission to open the file and I can see that in the drive.google.com web interface.
However I recently tested this on a chromebook, and when I open a file using the Files app, I get sent to my app, however it gets a 'File Not Found' error. When I check the permissions for that file, my app hasn't been given access to it.
If I open the file using drive.google.com and then try opening using the files app again, it works since my app has been given access to the file when I opened it using drive.google.com
Seems there is a bug in the Files app on Chrome OS here, where it doesn't set the permissions to give the app opening the file permissions to access it, whereas the web interface does that correctly. Has anyone else run into this and/or should I report this as a bug to Google?
Using ChromeOS 5116.115.4 + Chrome 33.0.1750.152
This was indeed a bug, and it's fixed in the upcoming chrome 34: https://code.google.com/p/chromium/issues/detail?id=332332

Configuring Drive SDK for mobile access

We have an app that integrates with google drive SDK, and open/new URLs are configured in the API console, working well on the desktop. The "Mobile Browser Support" checkbox is ticked. Still, when I open the Google Drive web page from a mobile browser (Ipad), clicking on a file link downloads the file instead of opening our application in the browser. Any idea if this is a config problem or a bug in the mobile Drive UI?
From what I've tried, on the mobile Google Drive website, a file is opened with your application instead of being downloaded only if the file has the mime-type of your application. This mime type looks like the following:
application/vnd.google-apps.drive-sdk.nnnnnnnnnn
You can find it by requesting information about your app using the API [1].
[1] https://developers.google.com/drive/v2/reference/apps/list