jorgefspereira / plaid_flutter

Plaid Link for Flutter. Integrates the native iOS, Android and Web SDKs.

Home Page:https://pub.dev/packages/plaid_flutter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

continueWithRedirectUri does not continue Plaid Link flow

alefischer13 opened this issue · comments

Hello,

I'm using PlaidLink.continueWithRedirectUri when testing OAuth app-to-app. After finishing the connect flow in the 3rd-party bank app, my application opens, I see "Continue with sign in" on the Plaid Link for a split second, and then it closes and sends me back to the page where I initiate PlaidLink.open(). I ensured that the redirect uri is the one we are expecting (oauth_state_id=), and other non-app-to-app flows work fine. I tried with both versions 2.2.1 and 2.2.2 and I get the same error.
Your help would be sincerely appreciated!

Alejandro

Hello,

I am experiencing the same issue. PlaidLink.onSuccess is never called. Here is the latest event that app receives from the PlaidLink.onEvent stream after calling PlaidLink.continueWithRedirectUri:
EXIT: {"viewName":"","exitStatus":"","mfaType":"","requestId":"ccjh9NuzQxQLFcw","timestamp":"2023-03-09T16:01:29Z","linkSessionId":"","institutionName":"","institutionId":"","institutionSearchQuery":"","errorType":"INVALID_REQUEST","errorCode":"INVALID_FIELD","errorMesssage":"invalid continuation token"}

Package version: 3.1.0
flutter --version:
Flutter 3.3.10
Framework • revision 135454af32 (3 months ago) • 2022-12-15 07:36:55 -0800
Engine • revision 3316dd8728
Tools • Dart 2.18.6 • DevTools 2.15.0

@jorgefspereira
I would be thankful for any help

Hello @jorgefspereira ,
Could you tell, please, if you have time/intention to dedicate some work to this bug in the nearest future?

@yaroslav-kahaniak I'll try to reproduce the error on my test example still this week.

@yaroslav-kahaniak can you give more the details of your test case (platform, token type, etc)?

@jorgefspereira , sure
Platform: iOS 16.2
Link configuration: LinkTokenConfiguration

Backend passes these params into the POST /link/token/create (https://plaid.com/docs/api/tokens/#linktokencreate) request:

{
   "products": ["transactions"],
   "country_codes": ["US"],
   "language": "en",
   ...
}

Mentioned earlier:
Package version: 3.1.0
flutter --version:
Flutter 3.3.10
Framework • revision 135454af32 (3 months ago) • 2022-12-15 07:36:55 -0800
Engine • revision 3316dd8728
Tools • Dart 2.18.6 • DevTools 2.15.0

The same issue for me

@jorgefspereira I wonder, are you planning to work on this issue any time soon? It is stopping the app I am working on from release. So if you are not going to work on that soon, I can take a closer look into the package source code and try to resolve it this weekend

@nzkn I was testing it right now. Can you give more info of your token creation process and the out put error? Fell free to take a closer look to the source code and try to fix the issue.

The plaid link is generated on the backed.
The following plaid config is used in node server:

plaid: {
    clientId: clientId,
    secret: secret,
    env: 'sandbox',
    version: '2020-09-14',
    tokenOptions: {
      client_name: clientName,
      products: ['auth'],
      country_codes: ['US'],
      language: 'en',
      redirect_uri: redirectUrl,
    }
  },

The server makes request to PlaidApi and returns link_token like this:

async getToken() {
  const plaidClient = new PlaidApi(configuration);
  const response = await plaidClient.linkTokenCreate({
    user: {
      client_user_id: req.user.id,
    },
    ...plaidConfig.tokenOptions,
  });
  return {linkToken: respoinse.data.link_token}
}

Before retrieving linkToken listeners are added in the app:

_plaidExit = PlaidLink.onExit.listen...
_plaidSuccess = PlaidLink.onSuccess.listen...

API call is made to the server, and plaidLink returned to launch Plaid:

var plaidLink = await getPlaidIntegrationLink();
var configuration = LinkTokenConfiguration(token: plaidLink.linkToken);
await PlaidLink.open(configuration: configuration);

After the sheet is opened, I go step-by-step and enable integration with Chase.

Neither PlaidLink.onSuccess nor PlaidLink.onExit gets called.

If you need some more details, please let me know. I think I can create demo project for the issue if required

Hi @nzkn,

To test this i created a simple firebase project to host my apple-app-site-association file.

I added my domain to the allowed redirect URIs:

Screenshot 2023-04-03 at 11 13 18

I created the link token with the following parameters:

Screenshot 2023-04-03 at 11 12 27

And ran the provided example of this plugin.

Simulator Screen Recording - iPhone 14 Pro - 2023-04-03 at 11 24 17

The flow worked ok, and I also received the onSuccess messages:

Screenshot 2023-04-03 at 11 24 23

Is there something I'm not taking into account? I'll also test today the continueWithRedirectUri function to be sure if something is wrong

@jorgefspereira Works fine for me too when I am not calling continueWithRedirectUri. I wonder, am I doing something wrong by calling PlaidLink.continueWithRedirectUri with the deep link that opens the app? Should I even call this function?

@nzkn no, you're right. continueWithRedirectUri should be call when your app receives a universal link. It should handle the support for app-to-app oauth. Let me try to check this app-to-app flow to see if something is wrong with it.

@jorgefspereira I put together a private repo with an example here and added you as a collaborator.

Could you take a look?

@nzkn @yaroslav-kahaniak I tested this extensively yesterday and came to the same invalid continuation token error:

Error Domain=PLKExitErrorInvalidRequestDomain Code=2 "" UserInfo={PLKExitErrorRawJSONKey=, PLKExitErrorDisplayMessageKey=, PLKExitErrorMessageKey=invalid continuation token, NSLocalizedDescription=, kPLKExitErrorCodeKey=INVALID_FIELD}

I also tested this OAuth App-to-App flow without calling continueWithRedirectUri and it seems to work fine. Which leads to the question "what is this function needed for?". At least for now it seems the only working solution is to not call the function at all.

There nothing I can do in the plugin code to fix the issue, so I contacted Plaid and I'm waiting for their response to this issue. I will leave the issue open until further news.

@jorgefspereira I put together a private repo with an example here and added you as a collaborator.

Could you take a look?

@jagloro Thank you for the example code. If you don't mind I'll add this working example of OAuth App-to-App to this repository to help newcomers with this type of integration.

@jorgefspereira
Thank you for the update! Let's wait for Plaid's response. Could you share the progress of Plaid's investigation into this thread once there is any?

@jorgefspereira Thank you for the update! Let's wait for Plaid's response. Could you share the progress of your Plaid's investigation into this thread once there is any?

Sure I'll add here as soon as they have some feedback.

@nzkn @yaroslav-kahaniak

According to Plaid, this error is the result of a race condition and a known issue. There has been some changes behind the scenes to the SDK and its no longer needed to call continueWithRedirectUri. In fact customers should refrain from calling that function because it can result in this issue.

In the newest version of the SDK (4.2.0), they renamed this function to resumeAfterTermination because it should only be called if we need to resume a Link session after the app was killed. The old documentation did state to call continueWithRedirectUri but it was recently updated to no longer make that recommendation.

I'll update the function name for the next release of the plugin (3.1.2).