We were able to get an access token in sandbox, using a different account. Now our customer has given us access to their account and we cannot generate an IAV token with it in production.
Below is the relevant code. Note in some cases, variables have been replaced with their values and urls have been altered to get around forum rules:
//get access token
$basic_credentials = base64_encode($dwolla_ak_key.’:’.$dwolla_sk_key);
$ch = curl_init(“https:__www.dwolla.com/oauth/v2/token”);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Basic '.$basic_credentials, ‘Content-Type: application/x-www-form-urlencoded;charset=UTF-8’));
curl_setopt($ch, CURLOPT_POSTFIELDS, ‘grant_type=client_credentials’);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = json_decode(curl_exec($ch));
$token= $data->access_token;
curl_close($ch);
DwollaSwagger\Configuration::$access_token = $token;
$apiClient = new DwollaSwagger\ApiClient("https:__api.dwolla.com");
//confirm can get info
$rootApi = new DwollaSwagger\RootApi($apiClient);
$root = $rootApi->root();
$accountUrl = $root->_links["account"]->href;
//try to get IAV token
$customersApi = new DwollaSwagger\CustomersApi($apiClient);
$myUrl = "https:__api.dwolla.com/customers/fd45c19e-d0cd-40b9-92a3-1cbbeffc3e22";
$iavToken = $customersApi->getCustomerIavToken($myUrl);
Here is the resulting error:
Fatal error: Uncaught exception ‘DwollaSwagger\ApiException’ with message ‘[403] Error connecting to the API (https:__api.dwolla.com/customers/fd45c19e-d0cd-40b9-92a3-1cbbeffc3e22/iav-token)’ in ./inc/dwolla-swagger-php-master/lib/ApiClient.php:315
Stack trace:
#0 ./inc/dwolla-swagger-php-master/lib/CustomersApi.php(846): DwollaSwagger\ApiClient->callApi(’/customers/fd45…’, ‘POST’, Array, ‘’, Array, Array)
#1 ./templates/dwolla-view-admin.php(148): DwollaSwagger\CustomersApi->getCustomerIavToken(‘https://api.dwo…’)
#2 ./admin.php(284): include(’/var/www/client…’)
#3 {main}
thrown in ./inc/dwolla-swagger-php-master/lib/ApiClient.php on line 315
