firefly-iii / firefly-iii

Firefly III: a personal finances manager
https://firefly-iii.org/
GNU Affero General Public License v3.0
16.34k stars 1.48k forks source link

Data Importer doesn't show helpful error when authenticating against Spectre with an App type API key #8381

Open PolygonError opened 10 months ago

PolygonError commented 10 months ago

Support guidelines

I've found a bug and checked that ...

Description

When attempting to setup the Data Importer to authenticate against Spectre with my API key I was greated with 'Impossible flow exception.' 500 Error. The logs show that this is caused by Spectre not supporting an endpoint with App API tokens, as shown in this log snippet

[2024-01-13 22:07:31] local.DEBUG: Now in AuthenticateController, calling middleware.
[2024-01-13 22:07:31] local.DEBUG: isReadyForSpectreStep("authenticate")
[2024-01-13 22:07:31] local.DEBUG: Now at App\Services\Spectre\AuthenticationValidator::validate
[2024-01-13 22:07:31] local.DEBUG: setParameters
[2024-01-13 22:07:32] local.ERROR: TransferException: Client error: `GET https://www.saltedge.com/api/v5/customers` resulted in a `400 Bad Request` response:
{"error":{"class":"AppsRestricted","message":"Not available for apps.","documentation_url":"https://docs.saltedge.com/ac (truncated...)

[2024-01-13 22:07:32] local.ERROR: Transfer exception leads to error.

This API key type is not mentioned in the docs when setting up a Salt Edge account.

Debug information

Debug information generated at 2024-01-13 22:12:56 Australia/Brisbane for Firefly III Data Importer version 1.4.0.

System information
ItemValue
Version1.4.0
Build#, base #67
SystemPHP 8.3.0, Linux, apache2handler
App information
ItemValue
TimezoneAustralia/Brisbane, Australia/Brisbane
Environmentlocal
Debug modefalse, cache 'file'
Log leveldebug, stack
Display errorsOff, ALL errors
BCscale12
Trusted proxies**
User information
ItemValue
User agentMozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0

Expected behaviour

The importer should notify the user that a Service API key is required for the Spectre data importer.

Steps to reproduce

  1. Go to the Firefly III Universal Data Import Tool front page after authenticating against Firefly III
  2. Press 'Import from Spectre'
  3. Put in a Spectre App ID and secret that are setup as an App API key on saltedge.com

Additional info

No response

JC5 commented 10 months ago

You're the first one I know of who did this, but I'll pick it up and see if I can give an proper message about this exception :+1:

github-actions[bot] commented 10 months ago

Hi there! This is an automatic reply. Share and enjoy

This issue has been marked as an enhancement. The requested enhancement to an existing feature will become a part of Firefly III or the data importer in due course.

If you come across this issue, please be aware there is NO need to reply with "+1" or "me too" or "I need this too" or whatever. Such comments are not helpful, and do not influence the roadmap. Your comment may be :skull: deleted. You can subscribe to this issue to get updates.

Thank you for your contributions.

dmshimself commented 3 months ago

I have a similar issue when trying to use the Spectre bank link. There is a prompt for the Spectre App ID and Spectre Secret which I have enetred, but after using Authenticate I get a 500 error and in the log I see what is shown below. Is there a way to specify the API key?

[2024-08-09 22:53:32] local.DEBUG: isReadyForSpectreStep("authenticate") [2024-08-09 22:53:32] local.DEBUG: Now at App\Services\Spectre\AuthenticationValidator::validate [2024-08-09 22:53:32] local.DEBUG: setParameters [2024-08-09 22:53:33] local.ERROR: TransferException: Client error:GET https://www.saltedge.com/api/v5/customersresulted in a400 Bad Request` response: {"error":{"class":"ApiKeyNotFound","message":"API key does not exist or is inactive.","documentation_url":"https://docs. (truncated...)

dmshimself commented 3 months ago

Having read the Saltedge docs a bit more, I realise you don't use the details from the account you create. You need to first create an API Key and then use the app and secret from that.