Google Spreadsheet App脚本刷新访问令牌 [英] Google Spreadsheet App script to refresh the access token

查看:89
本文介绍了Google Spreadsheet App脚本刷新访问令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下HTTP请求从关联的YouTube频道中检索数据.

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}

我正在使用Google电子表格应用脚本来处理上述请求.

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)

谢谢

Aneesh

推荐答案

您可以在 GitHub上进行检查教程如何在令牌过期时刷新令牌.

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

适用于Apps脚本的OAuth2是Google Apps脚本的库,该库提供了创建和授权OAuth2令牌以及在令牌到期时进行刷新的功能.该库使用Apps Script的新 StateTokenBuilder /usercallback端点来处理重定向.

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.

对于此库(以及一般的Apps脚本功能),URL始终采用以下格式:

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

其中{SCRIPT ID}是使用此库的脚本的ID.通过单击菜单项文件>项目属性",您可以在Apps脚本代码编辑器中找到脚本的ID.

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!

这篇关于Google Spreadsheet App脚本刷新访问令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆