Unable to create a token

(Jesse Lawler) #1

My sandbox test application isn’t functioning as your docs lead me to believe it will.

This code…

    const dwolla = require('dwolla-v2');

const appKey = 'REDACTED';
const appSecret = 'REDACTED';
const client = new dwolla.Client({
  key: appKey, 
  secret: appSecret,
  environment: 'sandbox', // optional - defaults to production
  grant_type: 'client_credentials'

await client.auth.client()
  .then(function(appToken) {
    return appToken.get('webhook-subscriptions');
  .then(function(res) {

…is supposed to give me a JSON response with my access_token (per https://docsv2.dwolla.com/#application-authorization). Instead, I’m getting this response:

	"_links": {
		"self": {
			"href": "https://api-sandbox.dwolla.com/webhook-subscriptions",
			"type": "application/vnd.dwolla.v1.hal+json",
			"resource-type": "webhook-subscription"
	"_embedded": {
		"webhook-subscriptions": []
	"total": 0

What is going on?

(Spencer Hunter) #3

Hi @EvilGenius, It looks like you’re taking the result of client.auth.client() and immediately returning a response from appToken.get(‘webhook-subscriptions’);

You could just call client.auth.client() to fetch a token after the client has been instantiated. Or create something like below that is called each time you need to fetch a new app token.

_newAppToken() {
    return new dwolla.Client({
        id: process.env.DWOLLA_KEY,
        secret: process.env.DWOLLA_SECRET,
        environment: 'sandbox'
    }).auth.client().then(appToken => {
      cache.put(KEY, appToken);
      return appToken;