4

I am using laravel as my framework with passport and guzzle installed. I am trying to get a password grant token from the server for my iPhone app that I am developing. This is how I am calling the api for the grant token

$http = new GuzzleHttp\Client;

$response = $http->post('http://your-app.com/oauth/token', [
    'form_params' => [
        'grant_type' => 'password',
        'client_id' => 'client-id',
        'client_secret' => 'client-secret',
        'username' => 'taylor@test',
        'password' => 'my-password',
        'scope' => '',
    ],
]);

return json_decode((string) $response->getBody(), true);

When I call this with all the correct data I get this error from the console.

GuzzleHttp\Exception\ConnectException: cURL error 7: 
Failed to connect to studious.test port 80: Connection refused (see 
http://curl.haxx.se/libcurl/c/libcurl-errors.html) in file /var/www/your-app/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php on line 185

I am also using Laradock for development and I have both your-app.com and www.your-app.com in my hosts file. From my research it seems that this could be a error due to some dns stuff. Not sure what in the world is going on with this.

In my host file I tried both putting my url with and with out the www.

John Dek
  • 123
  • 7

1 Answers1

2

You need to replace the request url with http://{nameofservice}/oauth/token, for example http://nginx/oauth/token, then it should work