python-samples icon indicating copy to clipboard operation
python-samples copied to clipboard

Obtaining Credentials Vs Using Credentials --- Separate Them For Clarity's Sake

Open mohsenBanan opened this issue 3 years ago • 0 comments

Summary

To the extent that this is sample code, clarity should be considered integral and fundamental.

Lack of clarity is an "issue". This "issue" applies to most google quickstart.py. All of those can benefit from this.

main() is doing two things:

  1. obtains the credentials
  2. uses the credentials to do some thing

So, on top of main() create a function called: obtain_credentials(scopes). It would return creds.

main() would then first do creds = obtain_credentials(scopes) and then comes the service usage part.

This way, the whole thing is a lot more clear and less duplicated (across all quickstart.py-s)

Expected Behavior

See above.

Actual Behavior

See Above.

Steps to Reproduce the Problem

See Above.

Specifications

  • Python version (python --version) = ALL
  • OS (Mac/Linux/Windows) = ALL

mohsenBanan avatar Jun 18 '22 18:06 mohsenBanan