react-plaid-link
react-plaid-link copied to clipboard
OAuth Error using Plaid Link
Hi Plaid,
I'm trying to enable Plaid Link for React, and I followed the instructions here: https://plaid.com/docs/link/web
for the React flow.
I verified that I'm getting a valid "link_token", but after calling open
after usePlaidLink
I receive an OAuth error:
oauth uri does not contain a valid oauth_state_id query parameter.
Any / all help is appreciated.
Thank You
Hi William!
We typically show this message when the receivedRedirectUri field is used incorrectly.
Link will be launched twice for OAuth flows: once before leaving Link to log in with the financial institution, and once after returning to Link from the financial institution.
Link must be configured differently during initialization and reinitialization.
When link is initialized the first time, the receivedRedirectUri field should be omitted or set to null. This is because this field is only used during link reinitialization. The receivedRedirectUri will contain an OAuth state id, which is used to connect the earlier half of a link session (before the user leaves Plaid for an institution's oAuth flow) to the later half of a Link session (after the user returns to Plaid from the OAuth flow). If you include this field when launching Link the first time, Plaid will attempt to associate this link session with an earlier link session, and will be unable to do so. Therefore, including this field on the first initialization will result in an error.
@phoenixy1
We are getting the same error
Getting the reinitialization link issue after adding Captial One bank and Platypus OAuth Bank in our Sandbox Environment.
-
The link platform we use in our project is: a. React Native. b. Web View
-
The environment we used is a Sandbox Environment.
-
Accounts we tested: a. Platypus OAuth Bank b. Capital One
-
The devices that are used for testing are: a. Android b. iOS
-
After adding Capital One Bank, we received the following response:
a. Link Token Configuration: export const params = { client_id: 'xxxxxxxxxxxxxxxxxxxxxxxx', secret: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx', user: { client_user_id: '' }, client_name: 'Monytor', products: ['transactions'], country_codes: ['US'], language: 'en', webhook: 'https://monytor.us/ampay/webhook/plaid', redirect_uri: 'https://monytor.us/ampay/oauth', };
b. Generated Link Token: "link_token":"link-sandbox-9b93cbdf-9f3d-48a0-9e6d-bbb5518a7cbd"
c. Initializing Link (First Link Initialization ): https://cdn.plaid.com/link/v2/stable/link.html?isWebview=true&token=link-sandbox-9b93cbdf-9f3d-48a0-9e6d-bbb5518a7cbd
d. Reinitializing Link: https://cdn.plaid.com/link/v2/stable/link.html?isWebview=true&token=link-sandbox-9b93cbdf-9f3d-48a0-9e6d-bbb5518a7cbd&receivedRedirectUri=https://monytor.us/ampay/oauth?oauth_state_id=752cf278-42ed-4c9f-96c8-eeaffaeaef54
e. Getting this after 'Reinitializing Link" plaidlink://event?event_name=EXIT&error_code=INVALID_FIELD&error_message=oauth%20uri%20does%20not%20contain%20a%20valid%20oauth_state_id%20query%20parameter&error_type=INVALID_REQUEST&request_id=Swm1JkExoQKlEVn&link_session_id=&status=requires_credentials×tamp=2022-10-18T11%3A56%3A26.782Z
We have tested both Captial One and Platypus OAuth Bank and we are getting the same error.
We have received the following error message: oauth uri does not contain a valid oauth_state_id query parameter
Could you kindly offer a solution to this issue as it is now preventing us from using the majority of the banks we use because they all are now OAuth Enabled.
@shiv71 If you've already tried the OAuth troubleshooting docs at https://plaid.com/docs/link/troubleshooting/#oauth-not-working, please submit a support ticket via the Plaid Dashboard!
I was getting this error developing an application locally that was using an external API to generate link tokens
. I had to ensure that the redirectUri
was set correctly such that it was being redirected to my local application. This meant creating a ngrok
tunnel and asking the API provider to add it to their list of whitelisted Plaid URLs in the Plaid dashboard.
Once this was completed my application worked. This is because Plaid link initializes twice. The first initialization returns the redirectUri
with the oauth_state_id
back to the original application. The second initialization requires the oauth_state_id
. Ex: https://<redirect_uri>.com/?oauth_state_id='...'
.
I know this is a repeat of what @phoenixy1 said, but I wanted to provide my own interpretation incase it's helpful for anyone else experiencing this issue in the future.
@phoenixy1 Hi Alex,
Quick question building off of this thread.
I am getting the same issue as the original post to this thread (OAuth when trying to open Link), but when I read the OAuth docs you guys have, it says a production env is "REQUIRED". Is this correct?
I'm trying to create an app where a single user has multiple Items/Bank institutions linked up under their account.
Thank you!
- Evan
@evanoshea21 The restriction in the docs is specifically about using OAuth in the Development environment. You can use OAuth with fake data in Sandbox without needing Production access, but if you want to use OAuth with real data, you need to have production access. Note that if you have production approval, then you can use OAuth in Development, but you can't use OAuth in development unless you also have production approval.
@phoenixy1 Ok thank you! I'll keep that in mind when working with real data. Best!
Going to close this issue now as it's quite old and does not appear to be an issue with the SDK itself.