Bug 366326

Summary: OFX direct download fails when OFX UID is expected by bank
Product: [Applications] kmymoney Reporter: Mike Wolfe <wolfemi1>
Component: generalAssignee: KMyMoney Devel Mailing List <kmymoney-devel>
Status: RESOLVED FIXED    
Severity: normal CC: jeffjl.kde, onet.cristian, ralf.habacker, swj
Priority: NOR    
Version: 4.8.0   
Target Milestone: ---   
Platform: Microsoft Windows   
OS: Microsoft Windows   
URL: https://mail.kde.org/pipermail/kmymoney/2015-December/002337.html
Latest Commit: Version Fixed In: 4.8.1,5.0.0
Sentry Crash Report:
Attachments: KMM patch to support OFX <CLIENTUID>
libofx patch to support <CLIENTUID>

Description Mike Wolfe 2016-08-01 13:29:44 UTC
Chase Bank (surely among others) requires a UID when using their OFX Direct Download service.  I don't think that KMyMoney sends a UID under any circumstances, as shown in the linked URL.

A quick fix was implemented, though I don't have the devel-list email handy.  Basically someone had patched the account properties so you could specify a UID of the proper length that would be sent to that account.  

Reproducible: Always

Steps to Reproduce:
1. Try to use OFX direct download at a bank that expects a UID response field
2. Download fails.
Comment 1 Jeff 2016-08-01 15:19:28 UTC
I don't recall a patch to KMM that fixed this. AqBanking implements the <CLIENTUID> and that is the workaround I remember.

The problem is that libofx does not implement <CLIENTUID>.

I have modified my copy of libofx to implement the <CLIENTUID> and hacked my copy of KMM to use it, and that works with my Chase accounts.  But I also made a lot of other libofx changes to better support investment accounts.  About a couple of weeks ago, I sent an email to the sourceforge libofx mailing list with my patch and got no response. Not sure what to do next.
Comment 2 Mike Wolfe 2016-08-02 13:51:28 UTC
Jeff: Yes, that sounds right; IIRC you used the UID from your Quicken install, right?

If it's a bug in ofxlib, that might be a hard one to get implemented if there's nobody maintaining it.  Would there be any chance of including it in the KMyMoney repository, or would that be too hairy?  At this point, I'd be okay with trying to build it myself from custom source, I just want to get my Chase card to work.
Comment 3 Jeff 2016-08-02 17:07:46 UTC
Mike: Yes, since Quicken already had a CLIENTUID for my accounts, and I had read elsewhere on the web that institutions tend to limit the number of UID's they accept per account (sometimes to one?), I set my KMM UID to what Quicken was using.  I'm still unclear on where the UID came from - I believe Quicken just "made it up" through some hash of the account name or something (if I'm remembering correctly what I tried to decode from their documentation). And I'm not sure if there's some extra transaction required with the bank the first time you use a CLIENTUID. If there was, Quicken did it for me and/or told me how to do it. I seem to recall doing something - maybe it was just deleting the online setup in Quicken and re-establishing it when Chase changed their policy. But I vaguely recall going to the bank website and doing something too.  Maybe it was just reauthorizing OFX access after the policy change.

With some effort, I could make patch files. I'd need to back out all my other changes, but just the CLIENTUID changes are pretty simple. But my KMM patch just assumes that libofx supports the CLIENTUID (thus why I call it a hack). Not sure what is the best way for KMM to know or figure out if it's supported before trying to use it. (Originally I thought it could eventually just require a newer version of libofx before compiling that in.)

I'll look into making patch files.
Comment 4 Jeff 2016-08-06 16:31:41 UTC
Created attachment 100481 [details]
KMM patch to support OFX <CLIENTUID>

"Client UID" field added to the online settings UI. I built KMM with this patch and connected to my Chase account OK using an updated libofx. This patch assumes libofx supports <CLIENTUID>.
Comment 5 Jeff 2016-08-06 16:34:08 UTC
Created attachment 100482 [details]
libofx patch to support <CLIENTUID>

libofx patch to support <CLIENTUID>. I did not rebuild my libofx with this patch because backing out all my other changes is a lot of work. But this should be sufficient to support <CLIENTUID>.
Comment 6 Swj 2016-08-09 17:11:35 UTC
Is there a not too difficult way I could get a windows binary with these patches in it?
Comment 7 Cristian OneČ› 2016-08-10 07:27:29 UTC
I can do that for the next release 4.8.1.
Comment 8 Thomas Baumgart 2016-08-10 19:39:29 UTC
Git commit a5e034816a8cb972b76bb8998e72e7ce689258e2 by Thomas Baumgart.
Committed on 10/08/2016 at 19:33.
Pushed by tbaumgart into branch '4.8'.

Added client uid support for OFX

Added a slightly modified and improved version of the patch which
is attached to bug #366326 and adds support for UI elements to enter a
clientuid and send it to LibOFX if it is supported there. In case the
LibOFX version available does not support clientuid the widget will be
shown disabled.

CMake detects the presence by checking the LibOFX header file to find
the clientuid field in the respective structure.
FIXED-IN: 4.8.1

M  +8    -0    CMakeLists.txt
M  +3    -0    kmymoney/plugins/ofximport/CMakeLists.txt
M  +6    -0    kmymoney/plugins/ofximport/dialogs/konlinebankingstatus.cpp
M  +17   -0    kmymoney/plugins/ofximport/dialogs/konlinebankingstatusdecl.ui
M  +9    -1    kmymoney/plugins/ofximport/dialogs/mymoneyofxconnector.cpp
M  +1    -0    kmymoney/plugins/ofximport/dialogs/mymoneyofxconnector.h
M  +4    -0    kmymoney/plugins/ofximport/ofximporterplugin.cpp

http://commits.kde.org/kmymoney/a5e034816a8cb972b76bb8998e72e7ce689258e2
Comment 9 Thomas Baumgart 2016-08-14 07:03:06 UTC
Git commit e8cd3bd98bba22b5d43cec8a602b81234bd277b3 by Thomas Baumgart.
Committed on 14/08/2016 at 07:01.
Pushed by tbaumgart into branch 'master'.

Added client uid support for OFX

Added a slightly modified and improved version of the patch which
is attached to bug #366326 and adds support for UI elements to enter a
clientuid and send it to LibOFX if it is supported there. In case the
LibOFX version available does not support clientuid the widget will be
shown disabled.

CMake detects the presence by checking the LibOFX header file to find
the clientuid field in the respective structure.

M  +6    -0    CMakeLists.txt
M  +4    -0    kmymoney/plugins/ofximport/CMakeLists.txt
M  +6    -0    kmymoney/plugins/ofximport/dialogs/konlinebankingstatus.cpp
M  +17   -0    kmymoney/plugins/ofximport/dialogs/konlinebankingstatusdecl.ui
M  +9    -1    kmymoney/plugins/ofximport/dialogs/mymoneyofxconnector.cpp
M  +1    -0    kmymoney/plugins/ofximport/dialogs/mymoneyofxconnector.h
M  +6    -2    kmymoney/plugins/ofximport/ofximporterplugin.cpp

http://commits.kde.org/kmymoney/e8cd3bd98bba22b5d43cec8a602b81234bd277b3
Comment 10 Thomas Baumgart 2016-08-15 05:50:18 UTC
Just got a note from our friends over at LibOFX that 0.9.11 has been released (https://sourceforge.net/projects/libofx/) with the patch included (personal contacts rock). So let's wait and see once that makes it into downstream.