无法使用气体从Reddit API获取访问令牌
我正在尝试使用获得的客户端ID和秘密 https://www.reddit.com/ prefs/apps
文档在这里: https://ads-api.reddit.com /docs/
应用程序名称是“报告”,这是“ Web应用程序”(选择脚本时我没有问题),
无论我尝试什么,我都会得到{“消息”:“不好的请求“,”错误”:400}
我正在使用Apts脚本/Google表格实现此功能,
我尝试了
Auth url:
https://www.reddit.com/api/v1/authorize?client_id=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxtype_type = code = code = relect_uri = https_uri = 3SGO3NPGK01QIUSSANY43FFNAUGG2Q6B%2FUSERCALLBACK& amp; amp; = adepc8xyajuigafm1are-n3gjrw-olvi08gr23y1ouqjplpgtpgtz6zpwtcpqra8kw79abqkxha1b8d90tb8b8b8b8b8b4jjjjjjjjjjjckkkzkkkzkkzkzjcggwdxjcgwdxj8lpdudnfuup nbnfuup anbnbnbnbnbnbnbnbnbnbnbnbnbnbnbhpnpdyquud qurpdyyquddyqudyqudyqudyqudyqudyquddyyqudyqudyqudyqudyquddyquud qurpnpn Q.RPNPD.ERPNPD.RPNPNPNPRIUP P2ZIF4WTT-YAPR8VBBRKHR0TC6ASCEWNQPE9SCSOCCRK6DITZ2SWFP_ZNA5RD03UP-F2HRJFMEORMPFFLZVFLZVFLZVFLZDBZVGDBZVGGGGGGGGGGGGGGGGGIPEEPEEPEEPEEPEEPEEPEEPEEPEEPEEPEEPEEPEEPEEPEEPEEPEEPEEPEEPEEPEEPEEPEEPEEPEEPEEPEEPEEPEEPEEPEEPEEPEEPEE UF8M_MBWKHOHO-69G9RNKCHMH-CTO_HGNP8-53TN_VICSQM2XF2XF2DQ_W& scope = adsread%20 history& puration& permp; permp; permap;
Redirect:
https://script.google.com/macros/d/1Nh3AKooeG8XH4rSTvEWLTf5l3Sgo3nPgK01qiusSany43fFNaUgg2q6b/usercallback?state=ADEpC8xyajUigAfm1arE-N3gjrw-OLvI08gR23Y1ouQJpLpGtZ6ZPWTcpQRa8kW79ABqkxha1B8d90tb8B4eianNmJjFgzKzjCGwdxJ8lpDUdyNF7YjNq_3ak8d6Co_arPUDuP-BnbH0qRSwuEacP2Zif4wTt-YapR8VBbrkhr0tc6aScewnQPe9sCsOccRK6dITZ2SWFP_ZNA5rd03uP-f2HRJfMEoRMPFFLzvfYs9CvgDbzIopee4k_6jqiEg02zK_BuQSOijkUweB3oBTGpcQxHsU1QcRmXoXuzjucN8uF8M_MbWKhOhO-69g9rnKcHmH-Cto_hgnP8-53tn_ViCsqM2xf2dQ_w&code=m0PsSaLd1kKVZs7jymk1Qn69hXsTQw#_
Request
curl -X POST https://www.reddit.com/api/v1/access_token \
-H 'content-type: application/x-www-form-urlencoded' \
-A 'username' \
-u xxxxxxxxxxxxx:yyyyyyyyyyyyyyyyyyyy \
-d 'grant_type=authorization_code&code=m0PsSaLd1kKVZs7jymk1Qn69hXsTQw#_&redirect_uri=https%3A%2F%2Fscript.google.com%2Fmacros%2Fd%2F1Nh3AKooeG8XH4rSTvEWLTf5l3Sgo3nPgK01qiusSany43fFNaUgg2q6b%2Fusercallback'
Response
{"message": "Bad Request", "error": 400}
I am trying to fetch the access token using obtained client ID and secret https://www.reddit.com/prefs/apps
The documentation is here: https://ads-api.reddit.com/docs/
The app name is "Reporting", this is selected as "web app" (I have no issues when script is chosen)
No matter what I try, I am getting {"message": "Bad Request", "error": 400}
I am implementing this using Apps script/Google Sheets
I have tried with
Auth URL:
https://www.reddit.com/api/v1/authorize?client_id=xxxxxxxxxxxx&response_type=code&redirect_uri=https%3A%2F%2Fscript.google.com%2Fmacros%2Fd%2F1Nh3AKooeG8XH4rSTvEWLTf5l3Sgo3nPgK01qiusSany43fFNaUgg2q6b%2Fusercallback&state=ADEpC8xyajUigAfm1arE-N3gjrw-OLvI08gR23Y1ouQJpLpGtZ6ZPWTcpQRa8kW79ABqkxha1B8d90tb8B4eianNmJjFgzKzjCGwdxJ8lpDUdyNF7YjNq_3ak8d6Co_arPUDuP-BnbH0qRSwuEacP2Zif4wTt-YapR8VBbrkhr0tc6aScewnQPe9sCsOccRK6dITZ2SWFP_ZNA5rd03uP-f2HRJfMEoRMPFFLzvfYs9CvgDbzIopee4k_6jqiEg02zK_BuQSOijkUweB3oBTGpcQxHsU1QcRmXoXuzjucN8uF8M_MbWKhOhO-69g9rnKcHmH-Cto_hgnP8-53tn_ViCsqM2xf2dQ_w&scope=adsread%20history&duration=permanent
Redirect:
https://script.google.com/macros/d/1Nh3AKooeG8XH4rSTvEWLTf5l3Sgo3nPgK01qiusSany43fFNaUgg2q6b/usercallback?state=ADEpC8xyajUigAfm1arE-N3gjrw-OLvI08gR23Y1ouQJpLpGtZ6ZPWTcpQRa8kW79ABqkxha1B8d90tb8B4eianNmJjFgzKzjCGwdxJ8lpDUdyNF7YjNq_3ak8d6Co_arPUDuP-BnbH0qRSwuEacP2Zif4wTt-YapR8VBbrkhr0tc6aScewnQPe9sCsOccRK6dITZ2SWFP_ZNA5rd03uP-f2HRJfMEoRMPFFLzvfYs9CvgDbzIopee4k_6jqiEg02zK_BuQSOijkUweB3oBTGpcQxHsU1QcRmXoXuzjucN8uF8M_MbWKhOhO-69g9rnKcHmH-Cto_hgnP8-53tn_ViCsqM2xf2dQ_w&code=m0PsSaLd1kKVZs7jymk1Qn69hXsTQw#_
Request
curl -X POST https://www.reddit.com/api/v1/access_token \
-H 'content-type: application/x-www-form-urlencoded' \
-A 'username' \
-u xxxxxxxxxxxxx:yyyyyyyyyyyyyyyyyyyy \
-d 'grant_type=authorization_code&code=m0PsSaLd1kKVZs7jymk1Qn69hXsTQw#_&redirect_uri=https%3A%2F%2Fscript.google.com%2Fmacros%2Fd%2F1Nh3AKooeG8XH4rSTvEWLTf5l3Sgo3nPgK01qiusSany43fFNaUgg2q6b%2Fusercallback'
Response
{"message": "Bad Request", "error": 400}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信您的目标如下。
https://www.reddit.com/api/v1/authorize?client_client_id=client_Id&Ampponseponse_tepe_type = code = code = code = code = code = code = random_state = random_state = random_state&am代码>使用浏览器,您需要使用Google Apps脚本创建的Web应用程序检索访问令牌。
在这种情况下,以下curl命令的请求由Google Apps脚本通过检索授权代码运行。
在这种情况下,以下Web应用程序的示例脚本如何?
示例脚本:
在脚本中设置变量后,请将修改后的脚本反映为Web应用程序。
注意:
在此修改后的脚本中,它假设您的函数
batcharchiveemail()
正常工作。请小心。如果您禁用V8运行时,我认为可以在没有上述修改的情况下使用脚本。但是在这种情况下,循环的过程成本将变得很高。 ref ref 在此上
在这种情况下,Web应用程序的设置必须为
执行为:ME
和谁可以访问该应用程序:任何人
for New IDE。请小心。I believe your goal is as follows.
https://www.reddit.com/api/v1/authorize?client_id=CLIENT_ID&response_type=code&state=RANDOM_STRING&redirect_uri=REDIRECT_URL&duration=DURATION&scope=SCOPE_STRING
with your browser, you want to retrieve the access token using Web Apps created by Google Apps Script.In this case, the request of the following curl command is run by Google Apps Script by retrieving the authorization code.
In this case, how about the following sample script of Web Apps?
Sample script:
After you set the variables in the script, please reflect the modified script to the Web Apps.
In this script, when you access your authorization URL of
https://www.reddit.com/api/v1/authorize?client_id=xxxxxxxxxxxx&response_type=code&redirect_uri=https%3A%2F%2Fscript.google.com%2Fmacros%2Fd%2F1Nh3AKooeG8XH4rSTvEWLTf5l3Sgo3nPgK01qiusSany43fFNaUgg2q6b%2Fusercallback&state=ADEpC8xyajUigAfm1arE-N3gjrw-OLvI08gR23Y1ouQJpLpGtZ6ZPWTcpQRa8kW79ABqkxha1B8d90tb8B4eianNmJjFgzKzjCGwdxJ8lpDUdyNF7YjNq_3ak8d6Co_arPUDuP-BnbH0qRSwuEacP2Zif4wTt- YapR8VBbrkhr0tc6aScewnQPe9sCsOccRK6dITZ2SWFP_ZNA5rd03uP-f2HRJfMEoRMPFFLzvfYs9CvgDbzIopee4k_6jqiEg02zK_BuQSOijkUweB3oBTGpcQxHsU1QcRmXoXuzjucN8uF8M_MbWKhOhO-69g9rnKcHmH-Cto_hgnP8-53tn_ViCsqM2xf2dQ_w&scope=adsread%20history&duration=permanent
and click "Arrow" button, the authorization code is sent to your Web Apps, and the access token and the refresh token are retrieved as follows.Note:
In this modified script, it supposes that your function
batchArchiveEmail()
works fine. Please be careful about this.If you disable the V8 runtime, I thought that the script might be worked without the above modification. But in that case, the process cost of the loop will become high. Ref By this, I would like to introduce this workaround.
In this case, the setting of Web Apps is required to be
Execute as: Me
andWho has access to the app: Anyone
for new IDE. Please be careful about this.