I’ve just started using Plaid. I’ve set up the quickstart app locally and it runs fine in sandbox mode. The Link panel loads fine, and I can log into an institution using the sandbox creds.
My .env
file looks like this:
PLAID_CLIENT_ID=xxxxxxxx
PLAID_SECRET=xxxxxxxx
PLAID_ENV=sandbox
PLAID_PRODUCTS=transactions
PLAID_COUNTRY_CODES=US,CA
PLAID_REDIRECT_URI=http://localhost:3000
I’d now like to check that Plaid will work with a few particular real/live institutions, so I’m attempting to update my quickstart app to work in development mode. To do this I am simply updating PLAID_SECRET to be my development secret key, and PLAID_ENV to be ‘development’.
When I now start the app, the start page no longer shows the ‘Launch Link’ button, but instead shows:
The logs suggest the issue is happening on the POST /api/create_link_token call. If I remove the error handling from that route function the logs show me the issue:
Traceback (most recent call last):
File "/Users/william/Personal/quickstart/python/venv/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/Users/william/Personal/quickstart/python/venv/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/Users/william/Personal/quickstart/python/venv/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/Users/william/Personal/quickstart/python/venv/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/Users/william/Personal/quickstart/python/venv/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/Users/william/Personal/quickstart/python/venv/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "server.py", line 196, in create_link_token
response = client.link_token_create(request)
File "/Users/william/Personal/quickstart/python/venv/lib/python3.8/site-packages/plaid/api_client.py", line 769, in __call__
return self.callable(self, *args, **kwargs)
File "/Users/william/Personal/quickstart/python/venv/lib/python3.8/site-packages/plaid/api/plaid_api.py", line 5566, in __link_token_create
return self.call_with_http_info(**kwargs)
File "/Users/william/Personal/quickstart/python/venv/lib/python3.8/site-packages/plaid/api_client.py", line 831, in call_with_http_info
return self.api_client.call_api(
File "/Users/william/Personal/quickstart/python/venv/lib/python3.8/site-packages/plaid/api_client.py", line 406, in call_api
return self.__call_api(resource_path, method,
File "/Users/william/Personal/quickstart/python/venv/lib/python3.8/site-packages/plaid/api_client.py", line 200, in __call_api
raise e
File "/Users/william/Personal/quickstart/python/venv/lib/python3.8/site-packages/plaid/api_client.py", line 193, in __call_api
response_data = self.request(
File "/Users/william/Personal/quickstart/python/venv/lib/python3.8/site-packages/plaid/api_client.py", line 452, in request
return self.rest_client.POST(url,
File "/Users/william/Personal/quickstart/python/venv/lib/python3.8/site-packages/plaid/rest.py", line 264, in POST
return self.request("POST", url,
File "/Users/william/Personal/quickstart/python/venv/lib/python3.8/site-packages/plaid/rest.py", line 223, in request
raise ApiException(http_resp=r)
plaid.exceptions.ApiException: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Server': 'nginx', 'Date': 'Sun, 16 May 2021 18:22:05 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '301', 'Connection': 'keep-alive'})
HTTP response body: {
"display_message": null,
"documentation_url": "https://plaid.com/docs/?ref=error#invalid-input-errors",
"error_code": "INVALID_API_KEYS",
"error_message": "invalid client_id or secret provided",
"error_type": "INVALID_INPUT",
"request_id": "EbCTgZkFdeYQQ8r",
"suggested_action": null
}
So it’s suggesting I’m using the wrong client id or secret, but I don’t understand. The client ID should be fine (it worked in sandbox mode), and the secret is definitely my secret for development mode (I’ve even tried generating a new one but no difference). Am I missing something?
Finally, if I use Postman to POST to https://development.plaid.com/link/token/create
to create a link token, using the same client ID and ‘development’ secret, it seems to work fine (i.e. I get a 200 response and brand new link token).
Any help is much appreciated!
2
Answers
Oops, well this would do it:
https://github.com/plaid/quickstart/blob/master/python/server.py#L84
It looks like the python Quickstart is hardcoded to ignore the environment variable set in the .env file. We’ll get that fixed. In the meantime, changing that line should fix your problem.
This is due to the fact that Python is hardcoded to Sandbox. This is being fixed and in the meantime, on line 84 of server.py, you can change it to:
"host=plaid.Environment.Development"