V2 Python SDK: Following Docs, Getting InvalidTokenType in Production



We were able to do transfers fine in sandbox mode, but in production they are not working.

We are trying to follow the docs as closely as possible and just want to get one successful transfer so we can start refining our code.

Here is our code:

client = dwollav2.Client(
    id = ...,
    secret = ...
app_token = client.Auth.client()
request_body = {
    '_links': {
        'destination': {
              'href': 'mailto:'+request.user.email
        'source': {
              'href': [hard-coded funding source]
    'amount': {
        'currency': 'USD',
        'value': balance
transfer = app_token.post('transfers', request_body)

And this is the error we get:

{"code":"InvalidTokenType","message":"The requested endpoint requires an account token."}

Are we missing something not mentioned in the docs?

Thank you in advance,


(Malcolm Mac Kinnon) #2

It appears you need to get the account token instead of the application token:
import dwollav2
client = dwollav2.Client(
key = os.environ[‘DWOLLA_APP_KEY’],
secret = os.environ[‘DWOLLA_APP_SECRET’],
environment = ‘sandbox’

account_token = client.Token(access_token = ‘…’, refresh_token = ‘…’)

First, to get the access_token and refresh_token, you go through Oauth2 process. The user will either set up new account or log in to existing Dwolla, and grants you permission scopes below.


state = binascii.b2a_hex(os.urandom(15))
auth = client.Auth(redirect_uri = ‘https://yoursite.com/callback’,
scope = ‘ManageCustomers|Funding’,
state = state, # optional
verified_account = True, # optional
dwolla_landing = ‘register’) # optional

redirect the user to dwolla.com for authorization


exchange the code for a token using the variables provided to the redirect_uri in the query string

token = auth.callback(req.GET)

You can read more about it here: