The Plaid integration does not remember the environment that you set, or ignores the environment that you set. If I setup Plaid with the development environment, it goes through the process as expected, authenticates with Plaid when adding a new account, imports the account etc, but when you try and sync, it does not use the chosen Plaid environment. For example, if I set it to Development through the setup process, when trying to Sync, the API passes "sandbox" in the token exchange.
Some times (1 out of 10), it remembers the environment for first sync, and then reverts back to Sandbox.
To replicate -
Enable Plaid Integration
Enter credentials for either development or production.
Go through Plaid auth and bank account access.
Sync every hour setting can be on or off, does not seem to affect anything.
Save Plaid settings.
Sync now
Check logs.
Module
integrations
Version
Frappe version - v14.48.1
ERPNext version - v14.39.0
Installation method
FrappeCloud
Relevant log output / Stack trace / Full Error Message.
Traceback with variables (most recent call last):
File "apps/erpnext/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_connector.py", line 74, in auth
self.client.Auth.get(self.access_token)
self = <erpnext.erpnext_integrations.doctype.plaid_settings.plaid_connector.PlaidConnector object at 0x7f3093657880>
e = InvalidInputError('provided access token is for the wrong Plaid environment. expected "development", got "sandbox"')
File "env/lib/python3.10/site-packages/plaid/api/auth.py", line 23, in get
return self.client.post('/auth/get', {
self = <plaid.api.auth.Auth object at 0x7f3098e91a50>
access_token = ********
_options = None
account_ids = None
options = {}
File "env/lib/python3.10/site-packages/plaid/client.py", line 103, in post
return self._post(path, post_data, is_json)
self = <plaid.client.Client object at 0x7f30923cae90>
path = '/auth/get'
data = {'access_token': 'access-sandbox-3dda2f7d-c180-41e8-b56d-252daddd19fc', 'options': {}}
is_json = True
post_data = {'client_id': '64f9f044e1b96a00144e76cd', 'secret': '********', 'access_token': 'access-sandbox-3dda2f7d-c180-41e8-b56d-252daddd19fc', 'options': {}}
File "env/lib/python3.10/site-packages/plaid/client.py", line 115, in _post
return post_request(
self = <plaid.client.Client object at 0x7f30923cae90>
path = '/auth/get'
data = {'client_id': '64f9f044e1b96a00144e76cd', 'secret': '********', 'access_token': 'access-sandbox-3dda2f7d-c180-41e8-b56d-252daddd19fc', 'options': {}}
is_json = True
headers = {'Plaid-Version': '2020-09-14', 'User-Agent': 'Plaid Python v7.2.1'}
File "env/lib/python3.10/site-packages/plaid/internal/requester.py", line 68, in _http_request
raise PlaidError.from_response(response_body)
url = 'https://development.plaid.com/auth/get'
method = 'POST'
data = {'client_id': '64f9f044e1b96a00144e76cd', 'secret': '********', 'access_token': 'access-sandbox-3dda2f7d-c180-41e8-b56d-252daddd19fc', 'options': {}}
headers = {'Plaid-Version': '2020-09-14', 'User-Agent': 'Plaid Python v7.2.1'}
timeout = 600
is_json = True
response = <Response [400]>
response_body = {'display_message': None, 'documentation_url': 'https://plaid.com/docs/?ref=error#invalid-input-errors', 'error_code': 'INVALID_ACCESS_TOKEN', 'error_message': 'provided access token is for the wrong Plaid environment. expected "development", got "sandbox"', 'error_type': 'INVALID_INPUT', 'request_id': 'jFl0UmeimhcLtZ5', 'suggested_action': None}
plaid.errors.InvalidInputError: provided access token is for the wrong Plaid environment. expected "development", got "sandbox"
Information about bug
The Plaid integration does not remember the environment that you set, or ignores the environment that you set. If I setup Plaid with the development environment, it goes through the process as expected, authenticates with Plaid when adding a new account, imports the account etc, but when you try and sync, it does not use the chosen Plaid environment. For example, if I set it to Development through the setup process, when trying to Sync, the API passes "sandbox" in the token exchange.
Some times (1 out of 10), it remembers the environment for first sync, and then reverts back to Sandbox.
To replicate - Enable Plaid Integration Enter credentials for either development or production. Go through Plaid auth and bank account access. Sync every hour setting can be on or off, does not seem to affect anything. Save Plaid settings. Sync now Check logs.
Module
integrations
Version
Frappe version - v14.48.1 ERPNext version - v14.39.0
Installation method
FrappeCloud
Relevant log output / Stack trace / Full Error Message.