So I am building a simple project, where I am trying to hit the Battle.net API and recieve a token.
I've already created a client on their platform and got a secret and password.
When I am trying to make a request with the build in Http facade included in Laravel 7, i get unauthorized, no matter what.
I am using their documentation to hit the client grant enpoint: https://develop.battle.net/documentation/guides/using-oauth
I've tried hitting it with the same headers and content in Insomnia, and inside that software it works.
The code I am using is the following:
public function index()
{
$key = env('BATTLE.NET_KEY');
$secret = env('BATTLE.NET_SECRET');
$response = Http::withHeaders([
'Authorization' => "Basic {$key}{$secret}",
'Content-Type' => 'multipart/form-data',
])->post('http://eu.battle.net/oauth/token', ['grant_type' => 'client_credentials']);
return dd($response);
}
What am I doing wrong? I must be missing something important. It's supposed to be simple. I've tried to wrap it in an associative array beginning with [form_params =>] but that didn't work neither. Also tried other content types to see if that worked but to no avail.