Access to fetch at https://accounts.google.com/o/oauth2/v2/auth has been blocked by CORS

The authentication flow must happen in a visible browsing context, not with a fetch request. In other words: You must navigate the current tab to (or open a new tab at) http://localhost:8000/api/mail/login, the tab will then be redirected to https://accounts.google.com/o/oauth2/v2/auth?… and this page becomes visible. Now the user must interact with that page to choose/confirm … Read more

Google API OAuth2, Service Account, “error” : “invalid_grant”

After some investigations I found, that Google API does not work as expected with your personal account @gmail.com. You should have organization domain account in Google in format you@your_organisation_domain Then, what is also pretty confusing, there is documentation at Google Drive API page, with “Delegate domain-wide authority to your service account” section not mentioned at … Read more

How to bypass entering authentication code to authorize my code everytime I use the YouTube Data API v3

Indeed there’s the possibility to save your credentials object the first time running successfully an OAuth authorization/authentication flow; then to load the credentials object from that file each time running the program for the n-th time, where n >= 2. Here is how I recommend to structure your code: import os, pickle from google_auth_oauthlib.flow import … Read more

How to programmatically remove a file from “share with me” in Google drive

The problem is that the user in question doesn’t own the file. After a lot of digging I realised that what you want to do is to remove the permissions for the user on the file in question. The first thing you need to do is run an about.get on the current user: return service.About.Get().Execute(); … Read more