I'm trying to get a token from Salesforce using Laravel and Guzzle. When trying through Postman, the login works fine. When I try my endpoint call, I get an unsupported_grant_type error.
Here is my code:
public function login(LoginRequest $request) {
$client = new Client();
$salesforce = new Request(
'POST',
'https://test.salesforce.com/services/oauth2/token',
[
'headers' => [
'Content-Type' => 'application/x-www-form-urlencoded'
],
'form_params' => [
'username' => $request->email,
'password' => $request->password,
'client_id' => '<super_secret_id>',
'client_secret' => '<super_secret_secret>',
'grant_type' => 'password'
]
]);
$response = $client->send($salesforce);
}