# Cannot get token anymore

**URL:** <https://discuss.dwolla.com/t/cannot-get-token-anymore/6202>\
**Category:** General\
**Created:** [September 21, 2020, 8:14pm UTC](https://discuss.dwolla.com/t/cannot-get-token-anymore/6202 "2020-09-21T20:14:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mjf017](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@mjf017](https://discuss.dwolla.com/u/mjf017)\
**Post date:** [September 21, 2020, 8:14pm UTC](https://discuss.dwolla.com/t/cannot-get-token-anymore/6202/1 "2020-09-21T20:14:35Z")

</div>

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

```auto
$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?

---

<div class="post-metadata">

**Author:** ![shreya](https://sea2.discourse-cdn.com/dwolla/user_avatar/discuss.dwolla.com/shreya/32/2154_2.png) [@shreya](https://discuss.dwolla.com/u/shreya)\
**Post date:** [September 22, 2020, 5:07pm UTC](https://discuss.dwolla.com/t/cannot-get-token-anymore/6202/2 "2020-09-22T17:07:47Z")

</div>

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](https://developers.dwolla.com/changelog#2019-02-21) as well as the [API reference documentation](https://docs.dwolla.com/#application-authorization). Let me know if you have any questions!
