【问题标题】:Unable to get oAuth token for BigCommerce once click app单击应用程序后无法获取 BigCommerce 的 oAuth 令牌
【发布时间】:2017-02-21 13:50:01
【问题描述】:

我是 BigCommerce 以及插件的完全菜鸟。最近还计划开发一款一键式应用程序,任何商店的用户都可以在他们的商店中安装该应用程序。我对php有很好的了解。所以,我可以编码,但不知道插件的流程。 要创建一个草稿应用程序,我访问了 devtools.bigcommerce.com 并创建了一个应用程序,将 Auth Callback url 定义为 https://amanangira.com/bCommerce/oauth.php 并将回调网址加载为https://amanangira.com/bCommerce/callBack.php

在 oauth.php 中我插入了以下代码

<?php

$data = array( "client_id" => "123456789",
                "client_secret" => "123456789",
                "redirect_uri" => "https://amanangira.com/bCommerce/callBack.php",
                "grant_type" => "authorization_code",
                "code" => $_GET["code"], "scope" => $_REQUEST["scope"], "context" => $_GET["context"], );

$postfields = http_build_query($data);

$ch = curl_init();
//$url = "https://api.bigcommerce.com/stores/wky4s3lfef/v3/";
$url = "https://login.bigcommerce.com/oauth2/token";
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch,CURLOPT_HTTPHEADER,array('Content-Type: application/x-www-form-urlencoded'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$output = curl_exec ($ch);
curl_close ($ch);

$obj = json_decode($output);

var_dump($obj); 
?>

现在,每当我在我的测试商店中安装应用程序时,它都会显示以下内容。

/var/www/html/angira/bCommerce/oauth.php:37: 对象(stdClass)[3] 公共'错误'=>字符串'redirect_uri_mismatch'(长度= 21) public 'error_description' => string '参数 redirect_uri 与注册的 URI 不匹配' (length=52)

请以尽可能简单的方式帮助解决上述问题。 谢谢。

【问题讨论】:

    标签: php api plugins oauth bigcommerce


    【解决方案1】:

    经过一番尝试和尝试,我终于偶然发现了解决方案。这是将 oauth.php 中的 redirect_uri 更新为应用程序配置中的 Auth Callback uri。

    "redirect_uri" => "https://amanangira.com/bCommerce/oauth.php"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-02
      相关资源
      最近更新 更多