我正在尝试在Google Apps脚本中使用StackExchange API的V2.2。
当我尝试发送POST请求以获取访问令牌时,问题出现在显式OAuth 2.0流的最后一步。 我收到404错误,但手动发出相同的请求(使用邮递员扩展)一切正常。
为了简化问题,如果我发送没有有效负载的POST请求,我会收到相同的404
var response = UrlFetchApp.fetch("https://stackexchange.com/oauth/access_token", { method: 'post', muteHttpExceptions: true }); Logger.log(response);在邮递员中,我收到400:
{ "error": { "type": "invalid_request", "message": "client_id not provided" } }我想这会是UrlFetchApp的一个问题,但有谁知道如何解决它? 谢谢!
I'm trying to use the V2.2 of StackExchange API in Google Apps Script.
The problem comes in the last step of the explicit OAuth 2.0 flow, when I try to send the POST request to obtain the access token. I receive a 404 error, but making the same request manually (using postman extension) everything is ok.
To simplify the problem, if I send this POST request with no payload I receive the same 404
var response = UrlFetchApp.fetch("https://stackexchange.com/oauth/access_token", { method: 'post', muteHttpExceptions: true }); Logger.log(response);while in postman I receive this 400:
{ "error": { "type": "invalid_request", "message": "client_id not provided" } }I guess this will be a problem with UrlFetchApp, but does anyone know how to solve it? Thanks!
最满意答案
该问题与Origin标头有关。
你不能直接从标题中删除,但你可以通过代理执行调用:)
The problem is related with the Origin header.
You cannot remove from the header directly but you can perform the call via a proxy :)
更多推荐
发布评论