1

First post in SO. Sorry if I ask dumb questions.

I want to upload photos from my computer to google photos.

Alas, I cannot find my feet and hands in the API. The OAuth 2.0 help page suggest to do it with a json, like so:

from oauth2client.client import flow_from_clientsecrets

flow = flow_from_clientsecrets('path_to_directory/client_secrets.json',
        scope='https://www.googleapis.com/auth/calendar', 
        redirect_uri='http://example.com/auth_return')

And I understand it demands to open a browser and get the reply in the redirection (which of course doesn't happen in my case)

My questions:

  1. Is there a way to do it in a headless machine?
  2. Assuming all I want is to use my local machine, and I don't own a DNS, what address should I use for the redirection?
  3. Does anyone have a reference code to use?

++++ Edit ++++

Thanks for the good people and their good answers, I managed to go half the way :-)

I can run this example, and list my 10 first files in drive. The problem appears when I call the build command. Original line says:

from googleapiclient.discovery import build
service = build('drive', 'v3', credentials=creds)

And this page lists all kind of APIs, missing the photos / picasa / whatever to make the photos be uploaded :-\

Any idea ?

Dorish
  • 56
  • 4
  • You can read it here: https://stackoverflow.com/questions/55224403/how-to-convert-postman-oauth-2-0-to-python/55224873#55224873 – Dmitrii Mar 20 '19 at 23:36
  • Redirect uses in apps, when they use google to auth clients. OAuth2 provides an option to obtain token manually, that is what u need. – Dmitrii Mar 20 '19 at 23:40
  • if you only want to upload to your own Photos account, then there is no need to write any code to perform the auth flow. You can obtain a Refresh Token using the OAuth playground. See https://stackoverflow.com/questions/19766912/how-do-i-authorise-an-app-web-or-installed-without-user-intervention – pinoyyid Mar 21 '19 at 01:44

0 Answers0