Facing issue in fetching token "We have encountered an issue fetching a token"

Hello Team,

After referring the Migration guide: dwolla.js to dwolla-web.js

We have configured the new dwolla-web.js by following all the migration steps. We were getting all results as expected till 28th Feb 2024. But since 29th Feb 2024 which is today we are getting the error message as “We have encountered an issue fetching a token”, while fetching the tokenUrl.

According to migration guide that code resembles in Step 4: Configure dwolla-web.js.

In the error: (err) => Promise.resolve(err), section we are getting the error message as above.
While when we dig into the php sdk dwolla code files we found response as “Cannot access offset of type string on string”, which is coming from the CURL client-tokens response api.

Please reach us out for the same ASAP.

Thank You!

1 Like

Hi @QA_Catch_All,

Thanks for posting! Could you please share more details around the drop-in component you were using when you encountered this error? Specifically the following would be helpful information to have for debugging:

  • Is this in Sandbox or Production?
  • Which drop-in component are you using?
  • Timestamp/timeframe of error
  • Is this only affecting one Customer or all Customers in your platform? Any Customer IDs you could share as examples?
  • Also, please share the relevant tokenUrl implementation code you have in your project.
1 Like

Hi @shreya,
Greeting for the Day!

We are using the sandbox environment. Below drop-in component we are using which is used for Create an unverified funding source and initiate micro-deposits for verification

Its affecting all users. Below is the code implemented in our environment.
=============== dwolla-funding-source-create code start ==========================

=============== dwolla-funding-source-create code end ==========================

=============== dwolla configuration of tokenUrl start ==========================
dwolla.configure({
environment: env,
styles: context + ‘/css/ach/dwolla.css’,
tokenUrl: ‘/ach/tokenUrl’,
success: (res) => Promise.resolve().then((result) => {
//success code
}),
error: (err) => Promise.resolve(err) // Here we get the error message as “We have encountered an issue fetching a token”.
});
=============== dwolla configuration of tokenUrl end ==========================
=================== Controller Code start =================================
public function tokenUrl()
{
$data = $this->request->getData();
$this->loadComponent(‘TrinetDirectPay’);
$result = $this->TrinetDirectPay->getIavTokenByRequest($data);
$this->ajaxResponse = $result[‘iavToken’][‘data’];
return $this->sendAjax(); // Here we get the error message as “Cannot access offset of type string on string”.
}
=================== Controller Code end ==================================
==================== tokenUrl response start ==================================
{
“message”: “Cannot access offset of type string on string”,
“url”: “/ach/tokenUrl”,
“code”: 500,
“file”: “/var/www/expense/app/src/Controller/AchController.php”,
“line”: 157
}
==================== tokenUrl end ==================================

Please provide your suggestions for the same.

Thank You!

Thanks for sharing your code details!

Could you please also share what the implementation for getIavTokenByRequest()? Also what are the contents of $result? Have you tried printing them out for debugging?

It seems to me like the code is still calling the /iav-token endpoint which has been deprecated. I wonder if that’s why the expected results aren’t being generated when you make the call to generate an IAV token.

For clarification, the tokens that the drop-in components need to be able to make client-side calls to the Dwolla API are /client-tokens. More information on how to generate these tokens can be found here in our docs - Generating Tokens For Drop-in Components | Dwolla API Documentation

Hope this is helpful!

Hello @shreya,
Greetings for the day!

Below is the code and methods we have used to get the token url. Its just a name that we have referred but we get the token url from dwolla clientTokens api itself.

public function tokenUrl()
{
$data = $this->request->getData();
$this->loadComponent(‘TrinetDirectPay’);
$result = $this->TrinetDirectPay->getIavTokenByRequest($data);
$this->ajaxResponse = $result[‘iavToken’][‘data’];
return $this->sendAjax();
}
public function getIavTokenByRequest($requestBody)
{
$this->objectUtils->useComponents($this, [‘Ach’]);
$token = $this->Ach->getCustomerClientTokenByBody($requestBody);

    if (!empty($token['status'])) {
        return [
            'status' => $token['status'],
            'message' => $token['data']->message,
            'iavToken' => ''
        ];
    }

    $iavToken = $token;

    return ['status' => 0, 'message' => '', 'iavToken' => $iavToken];
}

public function getCustomerClientTokenByBody($requestBody)
{
return $this->customerStrategy->getCustomerClientToken($requestBody);
}
public function getCustomerClientToken($reqBody){
try {
$result = $this->tokenApi->clientTokens($reqBody);
return $this->formatDwollaRespondData($result, ClientToken::class);
} catch (ApiException $e) {
return $this->formatDwollaRespondDataException($e);
}
}
==================== Response =======================
{
“_links”: {
“self”: {
“href”: “https://api-sandbox.dwolla.com/client-tokens”,
“type”: “application/vnd.dwolla.v1.hal+json”,
“resource_type”: “client-token”
},
“create-funding-sources”: {
“href”: “https://api-sandbox.dwolla.com/customers/9550d86b-1470-4cc8-87fe-21ea88e969e1/funding-sources”,
“type”: “application/vnd.dwolla.v1.hal+json”,
“resource_type”: “funding-source”
}
},
“token”: “XiuBVGLsnCebC6Vg2P3WqN5nr6EuhnUASGo7tu3g7JdMOgCG0z”
}

We are Glad to inform you that our code is successfully running now. Only one issue we are facing is of below console error.

Please provide your suggestions for the same.

Thank You!

Hi @QA_Catch_All,

Thanks for the update! Glad it’s working for you now!

For the first error, looks like it’s related to Content Security Policy (CSP). I’d probably recommend starting with with the CSP directives you have in place and addressing the errors the browser is flagging, like modifying the style-src directive to include the data: scheme explicitly, for instance. I’m afraid I don’t have much to add in terms of recommendations.

For the second error, it may be due to there already being another drop-in component in use, that are using dwolla-error and dwolla-success as well. This issue shouldn’t affect the implementation though.

1 Like