googlearchive/PyDrive

localhost isn't an authorized domain

Opened this issue · 5 comments

no version of localhost works for redirect urls, quickstart is also incorrect there is no web app option
to test, create new credentials, existing credentials dont have this issue
i suggest you figure out another way to authenticate at least for accessing your own account
ie: paste client secret statically into pydrive settings
or find an authorized remote domain that redirects to localhost

Getting Credentials:

Go Here:
Google Console

Login.
Create a project if one doesn't already exist (dropdown next to the upper lefthand honeycomb logo).
Click Enable APIs and Services.
Search for Google Drive; Select it.
Click Enable.
On Credentials tab, click 'Create Credentials -> Help Me Choose'

Under 'Where will you be calling the API from?':
Select Other UI
Select User Data
Click 'What Credentials do I Need?'
Enter a name for the creds.
Create OAuth client ID
Download creds.

Click Done. You're not done, though.

On the resulting screen, click the download arrow on the far right and save to your working directory.
Rename the downloaded file to 'client_secrets.json' (PyDrive people, please fix this to allow for arbitrary names.)

Code to authorize:

from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from oauth2client.client import GoogleCredentials


gauth = GoogleAuth()
gauth.CommandLineAuth()
#At warning, click Advanced -> Go to PyDrive-Assist
#Follow prompts, paste code back in your cell/commandline.
drive = GoogleDrive(gauth)

Now you're done!

I'm working on a wrapper for all of this over at PyDrive-Assist if you want to check it out! Link here.

i dont want to delete question because u provide helpful info, i may have misplaced a / at end of localhost settings, it does work, so my original question may be obsolete. thanks

@mgbvox After I click 'What Credentials do I Need?', I get a prompt to set up an OAuth consent screen. I don't seem to be able to get past this step by entering localhost? How can I circumvent this?

@joejoinerr I've actually found more success with GSpread for my purposes - their documentation is enlightening, at least. LINK

RE: PyDrive Assist, I'm refactoring a lot of the code and temporarily made the repo private. Check back in a bit.

I've created a new project and the "Help Me Choose" dialogue ended up creating a "Service account key". After that, I needed to create an "OAuth 2.0 client IDs".

There is a documentation here https://pythonhosted.org/PyDrive/quickstart.html