An example app to get you started on a google api cli app.
You could very well run this once in order to get your access and refresh token, or you could modify the code a bit and integrate it into your own app.
This example follows the recommendations of 'Option 2: Loopback IP address (macOS, Linux, Windows desktop)' listed on OAuth 2.0 for Mobile & Desktop Apps
[OAuth Flow] ---> [Loopback Redirect URI] ---> [Fetch Credentials] ---> [Output to Stdout]
-
git clone https://github.com/robbywashere/gmail-app-oauth-flow
-
Follow the Prerequisites on googles developer portal.
-
Download the credentials from 'Prerequisites' instructions into
gmail-app-oauth-flow
root directory as.config.json
-
Run
node main.js > .tokens.json
-
A browser window prompting you for an google auth flow (should) will pop-up
-
Complete auth, now
.tokens.json
will contain your token data
- Compatible on node 9+