Pass access token to web browser to be used with Dwolla.js

Hi,

I’m trying to use dwolla.js to create business verified customers and then add funding sources to them, but I’m not sure how to pass the access token back to the web browser. Currently, I have the webpage make a request to AWS Lambda, which uses my API credentials to generate an access token, but I’m not sure how to pass the token object back to the webpage since it is not JSON serializable.

What’s the correct way to accomplish this?

Thanks,
Josh

Hey Josh,

If you read the token as a string from the response res.body['token'], you should be able to pass it down to the client however you’d like. Hopefully that helps!

Thanks for the response, Stephen! I’m using python on the backend to generate the token and not quite sure how to read the token object as a string. Here’s the code I’m using after initializing the client:

app_token = client.Auth.client()

If I print the app_token or the string of the app_token, I get this:
<dwollav2.token.token_for..Token object at 0x7f82d7a16a30>

I see in the docs that it’s supposed to return a response that looks like this, but must be missing something:
{
“access_token”: “SF8Vxx6H644lekdVKAAHFnqRCFy8WGqltzitpii6w2MVaZp1Nw”,
“token_type”: “bearer”,
“expires_in”: 3600
}

How do I access the token in python?

Ah ok, that token should be kept private on your server. Instead, you will want to generate an IAV token and pass it to the client for use with dwolla.iav.start.

That example shows how to generate the IAV token for a specific customer that’s already been created in dwolla, but I need a token to be able to create customers with dwolla.js. I can’t figure out how to create an IAV token to use for this purpose, or find it in the docs or forums.

Sorry if I’m just being dense…is there another way I’m supposed to create Business Verified Customers? Let me know if I’m just approaching this the wrong way and not using the libraries as they’re meant to be used. I’ll outline my understanding below so you can correct any misunderstandings:

  1. Customer logs in to my web app (simple html & js page) and clicks to create their Business Verified Account and attach their bank account to it.
  2. When they click, a javascript function on the page is triggered to request an IAV token from my server (using python, but open to using another language if I have to) that will be used to create the Business Verified Customer.
  3. Pass the IAV token back to the webpage and use it with dwolla.iav.start to be able to create the customer and attach the funding source.

How do I generate an IAV token that can be used to create a customer?

No worries! That makes sense what you’re trying to do. Unfortunately Dwolla.js does not support creating customers at this time. Dwolla.js only supports a small subset of the Dwolla API. “IAV” is a method for creating funding sources that are instantly verified (as opposed to verified via micro deposits), and IAV tokens can only be used to create funding sources using Dwolla.js’s dwolla.iav.start.

I would check out the create a business verified customer guide for more info on how you can create a Business Verified Customer server-side. Then you can create an IAV token for that customer and pass it down to the client-side to add a verified bank via Dwolla.js.

Don’t hesitate to reach out if you have any more questions.

Got it, thanks Stephen!

1 Like