How tired I am of Google way how get API tokens

Google APIYou must:

  1. Create application and take its id and secret.
  2. Make a GET request to send secret and id with needed scopes of access.
  3. Obtain TEMPORARY access token and refresh token (first lives about 3000 – 5000 sec, the second can probably live infinite)
  4. Use this access token to GET something through REST, check if this token is not expires already.
  5. You want to GET something ELSE? First check if your token is not expired, then if expired – use refresh token to get NEW TEMPORARY token.
  6. Do something else.

Nice turn google! You are the best of masters of creating shitcode.

Before starting real work on google API and my own project with Google Drive I’ll learn pythons “requests” perfectly, first!

Thanks google you will make me smarter!

Example of shitcode which is needed to get the token first, then check if it is not expired and then request NEW if old was expired already.
It now is not working as expected, just some drafts. I’ve used this guy example: https://gist.github.com/SalvaJ/9722045 and Google Drive starter: https://developers.google.com/drive/v2/web/quickstart/python

BEWARE of shitcode!


What I want to do is to use python’s requests module to clear this shit out of code and make automation token renewal process.

But just one problem I can’t handle even in plans – is to make generation of this token from steps 2,3 – automate, because google wants me, as user, to click an “Agree” button right in browser, and there is no way to automate it without some way of shitcode and pseudo-browsers.

 

 

 

trianglesis

About trianglesis

Александр Брюндтзвельт - гений, филантроп, 100 гривен в кармане. Этот блог - "сток" моих мыслей и заметок. Достаточно одного взгляда на него, чтобы понять, что такой же бардак творится у меня в голове. Если вам этот бардак интересен - милости прошу.
Bookmark the permalink.