401 unauthorized error on new sandbox account

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

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)

Hi, I am using the node js package to initialize a client with my sandbox credentials:

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:

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

which responds with:

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.

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?

  key: "your_client_id",
  secret: "your_client_secret",

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

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

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!

2 Likes

Nice! Thanks for posting an update, @reid!