小编Pri*_*egi的帖子

如何通过在laravel中传递参数来获取内容类型application/x-www-form-urlencoded的响应

我已经在 Laravel https://sso/{custom_path}/token 中使用 Api 进行单点登录选项,就像使用 jwt 创建的 Api 一样。\n最后在 Web 应用程序中将标头中的访问令牌和内容类型传递给 Api 调用使用http客户端guzzle。\n使用内容类型application/x-www-form-urlencoded,并在form_params中使用参数。\n但作为响应,我缺少grant_type。当我在 form_parms 数组中传递 grant_type 时。有没有其他方法可以解决这个问题。任何有价值的回应都会被考虑。

\n

代码:

\n
$uri = $this->userTokenAuthencticateUrl();\n        $token = session('token')->access_token;\n        $params['header'] = [\n            "Content-Type: application/x-www-form-urlencoded",\n            "Authorization: Bearer $token"\n            ];\n        $params['form_params'] = array(\n                'grant_type' => 'xxxxx',\n                'response_include_resource_name' => 'xxx',\n                'audience' => 'xxxx', \n                'permission' => 'xxxxxx',\n            );\n            $response = Http::post($uri, $params);\n            dd($response->json());\n
Run Code Online (Sandbox Code Playgroud)\n

回应:

\n
array:2 [\xe2\x96\xbc\n  "error" => "invalid_request"\n  "error_description" => "Missing form parameter: grant_type"\n]\n
Run Code Online (Sandbox Code Playgroud)\n

php api single-sign-on laravel guzzle

2
推荐指数
1
解决办法
7063
查看次数

标签 统计

api ×1

guzzle ×1

laravel ×1

php ×1

single-sign-on ×1