TLDR: I am unable to get online stock quotes from within GnuCash and KMyMoney. It seems that something is wrong with the perl Finance::Quote module. What is the easiest way to fix this?
Background
Many free applications like KMyMoney and GnuCash use the perl library Finance::Quote to get stock, bond, and currency quotes from various websites. However, those websites often change their public-facing URLs, breaking this functionality for those applications. I am using a long-term support Linux distribution (Ubuntu LTS) because I like the stability, but there are no updates for this library in backports, so my software is now broken.
This recently happened with Ubuntu 22.04 LTS. KMyMoney installed with version 1.51 of Finance::Quote (libfinance-quote-perl, released in 2021), but a this is now failing due to recent changes on Yahoo. This is how I verified the installed version of this library:
perl -MFinance::Quote -e 'print "$Finance::Quote::VERSION\n"'
GnuCash has another utility that you can use to verify that this is the problem (replace yahoo_json with your data provider if different):
gnc-fq-dump -v yahoo_json AAPL
The error output looks something like the following:
Finance::Quote fields Gnucash uses:
symbol: AAPL <=== required
date: ** missing ** <=== recommended
currency: ** missing ** <=== required
last: **missing** <=\
nav: **missing** <=== one of these
price: **missing** <=/
timezone: <=== optional
** This stock quote cannot be used by GnuCash!
All fields returned by Finance::Quote for stock AAPL
stock field value
AAPL errormsg: Error retrieving quote for AAPL. Attempt to fetch the URL https://query1.finance.yahoo.com/v7/finance/quote?symbols=AAPL resulted in HTTP response 401 (Unauthorized)
AAPL last: missing
AAPL nav: missing
AAPL price: missing
AAPL success: 0
AAPL symbol: AAPL
We can tell it is a server problem because it is returning HTTP code 401.
What is the best way to get online quotes working again that does not involve upgrading the entire operating system?