Token generation timeout

Hello,
I am trying to test the Dwolla PHP SKD with simple steps provided in documentation but I am getting timeout error when trying to get Oauth token. Here is the php code and error I am getting. Any help?

<?php

//Configuring a client 
require_once("./private/vendor/autoload.php");
DwollaSwagger\Configuration::$username = '[remove]';
DwollaSwagger\Configuration::$password = 'removed';  


// For Sandbox
$apiClient = new DwollaSwagger\ApiClient("https://api-sandbox.dwolla.com");
var_dump($apiClient) ;

// Obtaining an access token

$tokensApi = new DwollaSwagger\TokensApi($apiClient);
$appToken = $tokensApi->token();
var_dump($appToken);
 

?>

( ! ) Fatal error: Uncaught DwollaSwagger\ApiException: API call to https://api-sandbox.dwolla.com/token timed out: a:37:{s:3:“url”;s:36:“https://api-sandbox.dwolla.com/token";s:12:“content_type”;N;s:9:“http_code”;i:0;s:11:“header_size”;i:0;s:12:“request_size”;i:0;s:8:“filetime”;i:-1;s:17:“ssl_verify_result”;i:20;s:14:“redirect_count”;i:0;s:10:“total_time”;d:0.045924;s:15:“namelookup_time”;d:0.000758;s:12:“connect_time”;d:0.026642;s:16:“pretransfer_time”;d:0;s:11:“size_upload”;d:0;s:13:“size_download”;d:0;s:14:“speed_download”;d:0;s:12:“speed_upload”;d:0;s:23:“download_content_length”;d:-1;s:21:“upload_content_length”;d:-1;s:18:“starttransfer_time”;d:0;s:13:“redirect_time”;d:0;s:12:“redirect_url”;s:0:"";s:10:“primary_ip”;s:13:“104.18.125.12”;s:8:“certinfo”;a:0:{}s:12:“primary_port”;i:443;s:8:“local_ip”;s:12:“192.168.1.56”;s:10:“local_port”;i:61816;s:12:“http_version”;i:0;s:8:“protocol”;i:2;s:16:“ssl_verifyresult”;i:0;s:6:“scheme”;s:5:“HTTPS”;s:18:“appconnect_time_us”;i:0;s:15:“connect_time_us”;i:26642;s:18:"namelookup_time_us”; in C:\wamp-new\www\xxxxxx\private\vendor\dwolla\dwollaswagger\lib\ApiClient.php on line 308

Hi @rizwanalam --Is this persistent? Are you able to wrap the request in a try/catch and catch the error and get the JSON response-body by calling the getResponseBody() method? That will show you the exact error response from the API.

Here’s an example:

try{
   $appToken = $tokensApi->token();
} catch (Exception $e) {
    echo 'Caught exception: ',  $e->getResponseBody(), "\n";
}

Hi Shreya,

This is persistent.

Here is the info I got from my capture. The first part is a dump of my header and the 2nd part is info after the post. At the end I also added the fiddler dump.

[24-Feb-2022 06:20:44 UTC] https://api-sandbox.dwolla.com
[24-Feb-2022 06:20:44 UTC] Array
(
[0] => Authorization: Basic eDFTMTFnMkFLeWMxUDRpNk1zbGpHTm9mUWhSTWVveE5iOWpFNW94SXJiZU16VnBxYk46Z0wwOXhGSjZLVEp4Y0Z1N09oSXZ4OW8zSVpTTEJobTZyTnFoQTVtMG10cE80NlBuU2k=
[1] => Accept:/
[2] => Content-type: application/x-www-form-urlencoded
[3] => Cache-Control: no-cache
[4] => Pragma: no-cache
[5] => Content-length: 29
)

[24-Feb-2022 06:20:44 UTC] Array
(
[url] => https://api-sandbox.dwolla.com/token
[content_type] => application/vnd.dwolla.v1.hal+json; profile=“http://nocarrier.co.uk/profiles/vnd.error/
[http_code] => 401
[header_size] => 831
[request_size] => 509
[filetime] => -1
[ssl_verify_result] => 20
[redirect_count] => 0
[total_time] => 0.246975
[namelookup_time] => 2.9E-5
[connect_time] => 0.012087
[pretransfer_time] => 0.099843
[size_upload] => 29
[size_download] => 82
[speed_download] => 333
[speed_upload] => 117
[download_content_length] => 82
[upload_content_length] => 29
[starttransfer_time] => 0.246928
[redirect_time] => 0
[redirect_url] =>
[primary_ip] => 127.0.0.1
[certinfo] => Array
(
)

[primary_port] => 8888
[local_ip] => 127.0.0.1
[local_port] => 57917
[http_version] => 2
[protocol] => 2
[ssl_verifyresult] => 0
[scheme] => HTTPS
[appconnect_time_us] => 99805
[connect_time_us] => 12087
[namelookup_time_us] => 29
[pretransfer_time_us] => 99843
[redirect_time_us] => 0
[starttransfer_time_us] => 246928
[total_time_us] => 246975
)

[24-Feb-2022 06:20:44 UTC] {“code”:“InvalidCredentials”,“message”:“Missing or invalid Authorization header.”}

From fiddler dump:
HTTP/1.1 401 Unauthorized
Content-Type: application/vnd.dwolla.v1.hal+json; profile=“http://nocarrier.co.uk/profiles/vnd.error/
Content-Length: 82
Connection: keep-alive
Access-Control-Allow-Origin: *
X-Request-Id: 6314d881-e842-4dd8-8da3-b21ba9fdf31e
CF-Cache-Status: DYNAMIC
Expect-CT: max-age=604800, report-uri=“https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct
Set-Cookie: __cf_bm=HO9ksogPJjCHlFvLZOnxp2foI1KpZbqgXgrD0k9fo0g-1645683645-0-AQyhvkImvxLDmLAGcFFN3UMUB/RysqxPP+kJhXg7gs+hKujpaT5vd/diHjqe4MRUgtYK1JbdnwPSB5ngsKIICkg=; path=/; expires=Thu, 24-Feb-22 06:50:45 GMT; domain=.dwolla.com; HttpOnly; Secure
Server: cloudflare
CF-RAY: 6e2697020fe7984f-SJC

{“code”:“InvalidCredentials”,“message”:“Missing or invalid Authorization header.”}

Hey @rizwanalam – apologies for the late reply. It sounds like the Authorization header value is where the issue is at. Are you able to confirm that the $username and $password are being set up correctly below as the key and secret respectively? I’d also check that you’re using the correct Sandbox credentials for your application as well.

The Authorization header value is "Basic " followed by the base64-encoded string of your key and secret in this format key:secret.

I did check and decode to verify and they are correct. I also compare my postman and they are matching.

Is something to do with ssl cert? I am not using ssl cert on my local but sending the https request.

That might be worth exploring. For what it’s worth, I tried the exact code you have above in my machine and I wasn’t able to recreate the issue. You could adding the following line to your file to get a debug output log that shows the SSL connection -

DwollaSwagger\Configuration::$debug = 1;

Example:

require('./vendor/autoload.php');

DwollaSwagger\Configuration::$username = '[remove]';
DwollaSwagger\Configuration::$password = 'removed'; 
DwollaSwagger\Configuration::$debug = 1;