Using OAuth for a simple command line script to access Google's data
martinfowler.com
martinfowler.com
Here is an example which uses Node, and obtains your access tokens. (https://github.com/openid/AppAuth-JS/blob/master/src/node_ap...)
Once you have that - you can make any API requests by using the correct Authorization headers.
The OAuth 2.0 Playground at https://developers.google.com/oauthplayground/ is another good resource for understanding refresh tokens and access tokens and how to get / exchange them.