nithinmurali / pygsheets

Google Sheets Python API v4
https://pygsheets.readthedocs.io/en/latest
Other
1.51k stars 220 forks source link

OAuth Out-Of-Band (OOB) migration for production app #586

Open francot opened 1 year ago

francot commented 1 year ago

Following this discussion: https://github.com/nithinmurali/pygsheets/discussions/530

pygsheets auth have to manage Out-Of-Band Oauth deprecation for production app.

Documentation at https://developers.google.com/identity/protocols/oauth2/resources/oob-migration report:

The OOB flow is being deprecated for all client types i.e. Web applications, Android, iOS, Universal Windows Platform (UWP), Chrome apps, TVs & limited-input devices, Desktop apps. This deprecation is only applicable to production apps (i.e apps with publishing status set to In Production. The flow will continue to work for apps with the Testing publishing status.

The workaround suggest in https://github.com/nithinmurali/pygsheets/discussions/530 works. At the end The flow generates a url like:

http://localhost/?state=FbsVj5ofyyuTF2O1ZmjF0Bs1jbh5Xx&code=--code-to-paste-for-auth--&scope=https://www.googleapis.com/auth/drive%20https://www.googleapis.com/auth/spreadsheets so you need to copy and paste code manually.

mpurnell1 commented 1 year ago

I also encountered this issue but was having to re-authorize my application every few days. I originally tried to use Google Workspaces as a workaround to the Testing status, because a workspace app can be marked as internal. This did not work as expected, and I didn't want to publish my app because it only needs access to a few documents owned by me.

My solution was to use a service account to authorize instead of OAuth. I followed the steps in this post and made sure to share the sheet I wanted to edit with the service account, then I was able to update my spreadsheets fully automatically, without having to follow the link or paste an authorization code.

francot commented 1 year ago

Thanks for your workaround. Actually I have published my app to avoid re-authorize every 7 days. Issue remains valid for published/production app