【问题标题】:Error While Generating Access Token For Shopify App为 Shopify 应用生成访问令牌时出错
【发布时间】:2016-03-31 08:07:12
【问题描述】:

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

但是现在生成访问令牌时似乎出错了。我收到了错误的回复:

{"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 oauth oauth-2.0 shopify


【解决方案1】:

【讨论】:

  • 感谢您的帮助,我已经一遍又一遍地检查了所有内容。发生这种情况的原因是因为我生成了另一个 ID 和密码,所以旧的不起作用,我认为解决方法是在刷新令牌的帮助下生成新的访问令牌
猜你喜欢
  • 2019-12-03
  • 2015-09-27
  • 1970-01-01
  • 2015-09-25
  • 1970-01-01
  • 2013-01-10
  • 2020-05-06
  • 2014-11-01
  • 2021-06-22
相关资源
最近更新 更多