【问题标题】:BigCommerce(Auth POST response) - 302 redirectBigCommerce(Auth POST 响应)- 302 重定向
【发布时间】:2018-03-03 09:52:20
【问题描述】:

目前正在尝试使身份验证安装正常工作,而当我阅读 BigCommerce 文档时,除了状态响应 200 之外的任何其他内容都被视为失败。

调试器日志:

node-bigcommerce:request Starting Request, with options. { path: '/oauth2/token',
  hostname: 'login.bigcommerce.com',
  method: 'POST',
  port: 443,
  headers:
   { 'User-Agent': 'node-bigcommerce/3.0.0',
     'Content-Type': 'application/x-www-form-urlencoded',
     'Content-Length': 394 } } +0ms

node-bigcommerce:request Sending Data: {"client_id":"123456789abcdefghikl","client_secret":"123456789abcdefghikl","redirect_uri":"https://xxxxx.xxxxx.com:8080/auth","grant_type":"authorization_code","code":"<code from query>","scope":"store_v2_customers_login store_v2_customers_read_only store_v2_default store_v2_orders_read_only store_v2_transactions_read_only","context":"stores/<our_store>"} +5ms

node-bigcommerce:request Status Returned: 302 +234ms

node-bigcommerce:request Headers Returned: {"content-type":"text/html; charset=utf-8","transfer-encoding":"chunked","connection":"close","status":"302 Found","cache-control":"no-cache, no-store","strict-transport-security":"max-age=31536000, max-age=31536000; includeSubdomains","pragma":"no-cache","x-xss-protection":"1; mode=block","x-request-id":"123456789abcdefghikl","location":"https://login.bigcommerce.com/login","p3p":"CP=\"ALL DSP COR CURa ADMa DEVa OUR IND COM NAV\"","x-content-type-options":"nosniff","date":"Fri, 02 Mar 2018 23:53:16 GMT","set-cookie":["_bc_login_session=123456789abcdefghikl; path=/; expires=Sat, 03 Mar 2018 00:08:16 -0000; secure; HttpOnly"]} +1ms
  node-bigcommerce:request Request complete +2ms
  node-bigcommerce:request RESOLVED BODY: <html><body>You are being <a href="https://login.bigcommerce.com/login">redirected</a>.</body></html> +0ms

当前使用节点 v9.7.0
使用 BigCommerce 文档中列出的“node-bigcommerce”。

我曾想过 BigCommerce 不喜欢在回调 url 中使用端口号,比如我的端口 8080。但如果是这种情况,当我尝试使用端口 80 或 443 时节点会出错。

当我在我的沙盒商店中安装草稿应用程序时,进度指示器覆盖将消失,BC 将呈现我的 AUTH 回调 url 发送的 HTML。但是,当您刷新页面时,该应用将从导航中消失,我确定这是上述问题的结果。

关于问题可能是什么的任何想法?

【问题讨论】:

    标签: node.js bigcommerce


    【解决方案1】:

    想通了,问题出在 node-bigcommerce 本身。

    由于 POST 请求内容类型是 x-www-form-urlencoded req.write() 传入了 dataString,它是来自 GET 的字符串化 json 有效负载。 BigCommerce 期望请求采用查询字符串的形式,因此您必须先获取有效负载并运行 querystring.stringify(),然后再运行 req.write()。

    之后,一切都很顺利。

    这适用于 API 版本 3、节点 9.7.1、BC 3.0.0

    【讨论】:

      猜你喜欢
      • 2018-07-15
      • 2021-10-20
      • 2016-09-15
      • 2016-06-21
      • 2018-09-28
      • 1970-01-01
      • 2015-07-29
      • 2011-11-02
      • 2018-03-18
      相关资源
      最近更新 更多