Cannot get token anymore

I had successfully integrated dwolla into my application. Now I am getting a 401 error connecting to the API. I have always used the following code to generate a token and never had an issue

$client_id = $key;
$client_secret = $secret;
$basic_credentials = base64_encode($client_id.':'.$client_secret);
$ch = curl_init('https://sandbox.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));
var_dump($data);
$token = $data->access_token;

curl_close($ch);

Has something changed on Dwolla’s side?

Hi @mjf017 – thanks for posting!

Not a recent change, but we’ve changed the token URL as well as the manner in which an application’s client credentials are sent to Dwolla to be inline with OAuth spec.

The new Dwolla token exchange endpoints are as follows,

https://api.dwolla.com/token
https://api-sandbox.dwolla.com/token

You can find more information in our Changelog as well as the API reference documentation. Let me know if you have any questions!