gpt4 book ai didi

api - YouTube API在 curl 请求中使用刷新 token

转载 作者:行者123 更新时间:2023-12-03 05:56:04 25 4
gpt4 key购买 nike

所以只使用curl请求:
https://www.googleapis.com/youtube/analytics/v1/reports?ids=channel== {channel id}&start-date = 2016-10-01&end-date = 2016-10-10&metrics = views&access_token = {accesstoken}

我想知道如何使用刷新 token 而不是访问 token ?我正在通过Google表格脚本使用此json请求,因此,如果可能的话,它必须全部包含在url中,并且没有JS或PHP。

任何帮助将不胜感激。

最佳答案

您不能直接在请求中使用刷新 token ,因此您将需要执行curl请求以从刷新 token 中获取访问 token 。然后,您可以在请求中使用访问 token 。
获取访问 token 的请求将如下所示:

https://www.googleapis.com/oauth2/v4/token?grant_type=refresh_token&refresh_token={your_refresh_token}&client_id={your_client_id}&client_secret={your_client_secret}
响应将采用以下格式:
{
"access_token" : "ya29.AHES6ZSuY8f6WFLswSv0HELP2J4cCvFSj-8GiZM0Pr6cgXU",
"token_type" : "Bearer",
"expires_in" : 3600,
"refresh_token" : "1/551G1yXUqgkDGnkfFk6ZbjMLMDIMxo3JFc8lY8CAR-Q"
}
如果需要,在标题“使用访问 token ”下有一些有关使用刷新 token 获取访问 token here的信息。
希望有帮助!

关于api - YouTube API在 curl 请求中使用刷新 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40158273/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com