php - 无法让 oAuth 与 Laravel 和 BigCommerce 应用程序一起使用
问题描述
我在使用BC PHP API库在 Bigcommerce 上设置“一键式应用程序”oAuth 时遇到问题。
目前的问题是获取实际的身份验证令牌。我尝试了各种方法,并相信这取决于(代码/上下文/范围)获取请求。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!';
}
}
解决方案
事实证明,这很好用。我正在使用 Runcloud 来管理应用程序,并且该click-jacking
选项阻止了应用程序屏幕上的 iframe!
推荐阅读
- websphere - ibm mq“无法连接到队列管理器”
- c# - C# FromSqlRaw 与字符串列表
- loops - KNIME:每行循环,从 -> 到值不同
- ms-word - ContentControl.insertHTML 越来越慢
- ios - 如何在调试模式下在 iOS 上分发 Flutter 项目?
- java - Soap Web 服务:Java 中的消息部分未被识别(它是否存在于服务 WSDL 中?)
- python - 谷歌驱动api与python
- c - memory allocation in the power of two vs multiple of eight
- java - 如何将数组列表值与前一个值进行比较并避免 IndexOutOfBoundException
- javascript - 如何在我的代码中从网站导入/检查代码?