Google Spreadsheet App script to refresh the access token

ε祈祈猫儿з 提交于 2019-12-11 06:13:22

问题


I am using the below HTTP request to retrieve data from my associated YouTube channel.

https://www.googleapis.com/youtube/analytics/v1/reports?ids=channel%3D%3D{MY_ASSOCIATED_CHANNEL_ID}&start-date=2016-08-01&end-date=2016-08-31&metrics=views&dimensions=video&filters=video%3D%3D{MY_VIDEO_ID}&max-results=10&sort=-views& access_token= {MY_ACCESS TOKEN}

I am using google spreadsheet app script to process the above request.

Could you please help me to setup an additional function which will refresh my access token before run the above function (I already have a REFRESH TOKEN)

Thanks,

Aneesh


回答1:


You can check on this GitHub tutorial how to refresh the tokens when they expire.

OAuth2 for Apps Script is a library for Google Apps Script that provides the ability to create and authorize OAuth2 tokens as well as refresh them when they expire. This library uses Apps Script's new StateTokenBuilder and /usercallback endpoint to handle the redirects.

For this library (and the Apps Script functionality in general) the URL will always be in the following format:

https://script.google.com/macros/d/{SCRIPT ID}/usercallback

Where {SCRIPT ID} is the ID of the script that is using this library. You can find your script's ID in the Apps Script code editor by clicking on the menu item "File > Project properties".

To do this, please follow the steps in the link provided above. Hope this helps!



来源:https://stackoverflow.com/questions/39635962/google-spreadsheet-app-script-to-refresh-the-access-token

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!