0

I'm trying to authenticate in an api sandbox but error 400 is returning me, I already got it through an extension but in the code with guzzle it's not working, I need to pass the Header parameter with encrypted authorization as it is.

 $client = new \GuzzleHttp\Client(['headers' => ['Authorization' => 'Basic $token']]);
                  $response = $client->post('', [
                        'grant_type' => 'password',
                        'scope' => 'forintegration',
                        'username' => '',
                        'password' => '',
                  ]);
                
                  $body = $response->getBody();
                  print_r(json_decode((string) $body));
CodeIn
  • 31
  • 7
  • Look here https://stackoverflow.com/questions/25040436/guzzle-handle-400-bad-request – STA Jun 25 '20 at 05:59

1 Answers1

0

Working with:

$client = new \GuzzleHttp\Client();
              $url = "";
              $response = $client->request('POST', $url, [ 
                'headers' => [
                     'Accept' => 'application/x-www-form-urlencoded', 
                     'Authorization' => 'Basic $token'
                ],
                'form_params' => [
                     'grant_type' => 'password', 
                     'scope' => 'forintegration', 
                     'username' => '',
                     'password' => ''
                ] 
            ]);
            
              $body = $response->getBody();
              print_r(json_decode((string) $body));
CodeIn
  • 31
  • 7