无法获得oAuth以与Laravel和BigCommerce App一起使用

时间:2018-11-20 08:20:57

标签: php laravel oauth bigcommerce

我在使用BC PHP API库在Bigcommerce上设置“一键式应用” oAuth时遇到问题。

当前的问题是获取实际的身份验证令牌。我尝试了各种方法,并认为这取决于(Code / Context / Scope)获取请求。它们每次都以null的形式返回。

我都尝试过:

$request->query('code');
$request->get('code');

在BC应用程序启动屏幕上,向我显示:

Trying to get property 'access_token' of non-object 

这当然是因为令牌返回null。

这是我在Laravel的控制人

namespace App\Http\Controllers;

use \Illuminate\Http\Request;
use Bigcommerce\Api\Client as Bigcommerce;

class BController extends Controller
{
    //
    public function index(Request $request)
    {
      $object = new \stdClass();
      $object->client_id = 'xxxxxxxxxxxxxx';
      $object->client_secret = 'xxxxxxxxxxxxxxxx';
      $object->redirect_uri = 'https://linkto/process_oauth_result';
      $object->code = $request->query('code');
      $object->context = $request->query('context');
      $object->scope = $request->query('scope');
      Bigcommerce::useJson();

      $authTokenResponse = Bigcommerce::getAuthToken($object);

      // configure BC App
      Bigcommerce::configure([
     'client_id' => env('xxxxxxxxxxxxxx'),
     'auth_token' => $authTokenResponse->access_token,
     'store_hash' => 'xxxxxxx'
   ]);

        Bigcommerce::verifyPeer(false);

        return 'Success!';
    }
}

1 个答案:

答案 0 :(得分:0)

事实证明这很好。我正在使用Runcloud来管理应用程序,并且click-jacking选项阻止了应用程序屏幕上的iframe!