Laravel HTTP x-www-form-urlencoded Request Body
Sometimes we need to send x-www-form-urlencoded
form data. Most of the time, we get these types of errors:
- unsupported_grant_type
- 'grant_type' must be set
If you would like to send data using the application/x-www-form-urlencoded
content type, you should call the asForm
method before making your request:
$response = Http::withBasicAuth($client, $client_secret)
->asForm()
->post($endpoint, [
'grant_type' => 'authorization_code',
'code' => $request->code,
'redirect_uri' => $redirect_url
])
->json();

Md Obydullah
https://shouts.dev/obydul