# 401 unauthorized error on new sandbox account

**URL:** <https://discuss.dwolla.com/t/401-unauthorized-error-on-new-sandbox-account/8670>\
**Category:** API Support\
**Created:** [January 5, 2023, 11:12pm UTC](https://discuss.dwolla.com/t/401-unauthorized-error-on-new-sandbox-account/8670 "2023-01-05T23:12:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![reid](https://avatars.discourse-cdn.com/v4/letter/r/439d5e/32.png) [@reid](https://discuss.dwolla.com/u/reid)\
**Post date:** [January 5, 2023, 11:12pm UTC](https://discuss.dwolla.com/t/401-unauthorized-error-on-new-sandbox-account/8670/1 "2023-01-05T23:12:45Z")

</div>

Hello, I registered for a sandbox account yesterday and clicked the link to verify my email, but I am getting a 401 unauthorized error in my application when I use the sandbox credentials. Looking through previous posts here, it seems something might have gone wrong with my email verification. Any help would be greatly appreciated!

Thanks,  
Reid

---

<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:** [January 6, 2023, 5:00pm UTC](https://discuss.dwolla.com/t/401-unauthorized-error-on-new-sandbox-account/8670/2 "2023-01-06T17:00:37Z")

</div>

Hi @reid – could you share with the us the details of your request and response (minus your Sandbox credentials). Are you using Postman, cURL or some other language to make calls to the API? Any details would be helpful!

I would also make sure that you are using the correct credentials and are calling the Sandbox endpoint (`api-sandbox.dwolla.com`) and not Production (`api.dwolla.com`)

---

<div class="post-metadata">

**Author:** ![reid](https://avatars.discourse-cdn.com/v4/letter/r/439d5e/32.png) [@reid](https://discuss.dwolla.com/u/reid)\
**Post date:** [January 6, 2023, 5:26pm UTC](https://discuss.dwolla.com/t/401-unauthorized-error-on-new-sandbox-account/8670/3 "2023-01-06T17:26:29Z")

</div>

Hi, I am using the [node js package](https://www.npmjs.com/package/dwolla-v2) to initialize a client with my sandbox credentials:

```auto
import { Client } from 'dwolla-v2';

// Initialize dwolla
const dwolla = new Client({
  key: process.env.DWOLLA_APP_KEY ?? '',
  secret: process.env.DWOLLA_APP_SECRET ?? '',
  environment: "sandbox", // defaults to 'production'
});

export default dwolla;

```

and then testing the connection with:

```auto
  //gets all customers in the dwolla environment
  async function getDwolla() {
    dwolla.get("customers").then((res) => console.log(res.body));
  }

```

which responds with:

```auto
error: POST https://api-sandbox.dwolla.com/token 401
{"error":"invalid_client"}

```

I just tried in Postman as well and received a 401 error after using my sandbox credentials in the request.

---

<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:** [January 6, 2023, 8:50pm UTC](https://discuss.dwolla.com/t/401-unauthorized-error-on-new-sandbox-account/8670/4 "2023-01-06T20:50:45Z")

</div>

Thank for sharing the above, @reid.

Could you try the above code by using the key and secret directly instead of reading it from the environment variables and see if that works?

```auto
  key: "your_client_id",
  secret: "your_client_secret",

```

As for the failure using Postman, could you share a screenshot?

---

<div class="post-metadata">

**Author:** ![reid](https://avatars.discourse-cdn.com/v4/letter/r/439d5e/32.png) [@reid](https://discuss.dwolla.com/u/reid)\
**Post date:** [January 6, 2023, 10:00pm UTC](https://discuss.dwolla.com/t/401-unauthorized-error-on-new-sandbox-account/8670/5 "2023-01-06T22:00:27Z")

</div>

That worked @shreya, and I found out that I had to prepend my environment variables with REACT\_APP\_ to get it working.

```auto
const dwolla = new Client({
  key: process.env.REACT_APP_DWOLLA_APP_KEY as string,
  secret: process.env.REACT_APP_DWOLLA_APP_SECRET as string,
  environment: "sandbox"
});

```

Thank you for the help!

---

<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:** [January 9, 2023, 2:50pm UTC](https://discuss.dwolla.com/t/401-unauthorized-error-on-new-sandbox-account/8670/6 "2023-01-09T14:50:17Z")

</div>

Nice! Thanks for posting an update, @reid!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/dwolla/original/2X/1/1b70808226fb9abeaaf7386224caffb453efb690.png) [@system](https://discuss.dwolla.com/u/system)\
**Post date:** [January 5, 2024, 11:12pm UTC](https://discuss.dwolla.com/t/401-unauthorized-error-on-new-sandbox-account/8670/7 "2024-01-05T23:12:51Z")

</div>

This topic was automatically closed after 365 days. New replies are no longer allowed.
