python google-api quickstart examples are poorly documented

Viewed 158

They say its a quickstart but idk lol

Any way I have attempted to connect to the google api with Ruby for an entire week and eventually said I am going to see if its easier with python, turns out it is not.

I have added my redirect URI in the Oauth Credential. I have tried using a web applications type, a desktop app, and a tv or limited input device.

All of them return errors.

  1. Error 400: redirect uri mismatch
  2. Error 400: Invalid Request
  3. Couldnt Log you in, The browser you are using doesnt support javascript, please try signing in in a browser with javascript enabled.

It keeps trying to use a localhost uri even when its set to my authorized one in the json credentials....

Is there anyone who can help me just get a basic example connection to the API working I am starting to lose hope that it is even realistic to try and build on an API as chaotic as this has been in my research so far. Everywhere you go you see devs wasting 5 days on something that should take an hour.

Edits BELOW !!!!

This has been so confusing I had to just go to trying to make a basic api call and eliminate all of the chaos brought in by these deprecated dependencies.

I have moved to just trying to get data back using post man and this tutorial >> https://medium.com/kinandcartacreated/google-authentication-with-postman-12943b63e76a

I have successfully been able to generate an Auth token using ONLY an OAuth2.0 Credential that is of TYPE 'Web Application'

enter image description here

However when trying to hit this endpoint.... GET https://admin.googleapis.com/admin/directory/v1/customer/MY-CUSTOMER-ID/devices/mobile?projection=FULL

I get the following error... enter image description here

I know that in the end I will need to have a service account for this application configured properly, however given the wild goose chase that this has been I have been putting it off to keep the experiment controlled.

I will be working hard on trying to demystify this service account authorization for the next 4 hours atleast...

2 Answers

I had some difficulty getting the "quickstart" going as well.

There are a few things that should be taken into account that, in fact, aren't clearly documented.

After setting up the credentials in the respective page in Google Console as indicated in the documentation, you should download the json file and save it to the same directory as the script.

Take note that the quickstart has its own local server that it starts up when you run it. You can set the port in this line in the script. For example:
creds = flow.run_local_server(port=3000)

Then when you configure your credentials in the project, you would set the redirect URI to http://localhost:3000/

It does require some patience, because as noted, it does sometimes take several hours until the credentials settings in the Console take effect!

Related