Thanks for reviewing. Indeed this is a bandaid to expand the usability of the OAuth implementation. As I've written on the redmine issue as well https://redmine.postgresql.org/issues/6627 I've tested my usecase with a modified scope by patching the oauth2.py file in production. That works well for authentication from Microsoft Azure AD. Also Shy N reported this method to work.
Good to hear that.
This patch just makes the scope configurable so it can be adopted to different use-cases.