How to access a gmail account I own using Gmail API?

前端 未结 2 960
执笔经年
执笔经年 2021-02-07 04:10

I want to run a node script as a cronjob which uses Gmail\'s API to poll a gmail account I own.

I am following these quickstart instructions:

I\'m stuck

2条回答
  •  迷失自我
    2021-02-07 04:27

    I also find that the documentation can be confusing at times, but what you want to to is actually pretty straight forward once you get it:

    1. Register your App at Google, and say what APIs you want your App to have access to (only the Gmail API in this case). This will give you two strings, a client_id and a client_secret (which is the content of the client_secrets.json-file above).
    2. Since you are just going to write a script for your own account only, you don't need a http-server. The Oauth Playground will suffice. Press the Settings Cog on the top right and use your own OAuth credentials.
    3. Select the Gmail API in the list of APIs and follow the outlined steps.

    Now you have an access_token and a refresh_token you can use to keep your script going indefinitely!

提交回复
热议问题