gpt4 book ai didi

java - 为 Shopify 应用程序生成访问 token 时出错

转载 作者:行者123 更新时间:2023-12-02 08:20:34 25 4
gpt4 key购买 nike

我已经为 Shopify 商店构建了一个应用程序,直到昨天它都运行良好。链接到创建 Shopify 应用程序所遵循的文档:https://docs.shopify.com/api/authentication/oauth

但是现在生成访问 token 时似乎出现错误。我在响应中收到错误:

{"error":"795: unexpected token at 'code=<my-code>\u0026client_secret=<my-secret>\u0026client_id=<my-client-id>'"}

以下是用 Google App Script 编写的代码要点。

function doPost(e)
{
try
{
var client_id = e.parameter['client_id'];
var client_secret = e.parameter['client_secret'];
var code = e.parameter['code'];
var shopUrl = e.parameter['shopUrl'];

var headers = {
"Accept":"application/json",
"Content-Type":"application/json"
};

var payload = {
"client_id" : client_id,
"client_secret" : client_secret,
"code": code
};

var options =
{
"method" : "POST",
"payload" : payload,
"headers" : headers,
"muteHttpExceptions":true
};

var response = UrlFetchApp.fetch(shopUrl, options);
var data = response.getContentText().split('"')[3];

//response variable gives the following response
// {"error":"795: unexpected token at 'code=<my-code>\u0026client_secret=<my-client-secret>\u0026client_id=<my-client-id>'"}

return ContentService.createTextOutput(data).setMimeType(ContentService.MimeType.TEXT);
}//try
catch(e)
{
//log the exception
}//catch
}//doPost

有人遇到过同样的错误吗?请帮忙

最佳答案

关于java - 为 Shopify 应用程序生成访问 token 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34460240/

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