Skip to content

Intermittent HTTP 401 returned from Yahoo API #206

@centic9

Description

@centic9

I am calling the API at a frequency of 5 minutes for around 10 stocks, which worked fine for quite some time.

Since a few days, the Yahoo API still works, but sometimes fails with HTTP 401.

There have previously been issues with some cookies which lead to this error, e.g. #130

Is this a re-occurrence of this?

If the API now really would need authentication via a Yahoo-ID and OAuth it would fail always, not intermittently, so seems at least some similar issue.

Can I investigate this some more? Logging? Debugging?

Code:

Stock stock = YahooFinance.get("ORCL");

Exception

Exception in thread "main" java.io.IOException: Server returned HTTP response code: 401 for URL: https://query1.finance.yahoo.com/v7/finance/quote?symbols=ORCL
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
        at java.base/sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1974)
        at java.base/sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1969)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at java.base/sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1968)
        at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1536)
        at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1520)
        at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:250)
        at yahoofinance.quotes.query1v7.QuotesRequest.getResult(QuotesRequest.java:74)
        at yahoofinance.YahooFinance.getQuotes(YahooFinance.java:381)
        at yahoofinance.YahooFinance.get(YahooFinance.java:98)
        at yahoofinance.YahooFinance.get(YahooFinance.java:82)
        ...
Caused by: java.io.IOException: Server returned HTTP response code: 401 for URL: https://query1.finance.yahoo.com/v7/finance/quote?symbols=ORCL
        at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1924)
        at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1520)
        at java.base/[java.net](http://java.net/).HttpURLConnection.getResponseCode(HttpURLConnection.java:527)
        at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:334)
        at yahoofinance.util.RedirectableRequest.openConnection(RedirectableRequest.java:54)
        at yahoofinance.util.RedirectableRequest.openConnection(RedirectableRequest.java:34)
        at yahoofinance.quotes.query1v7.QuotesRequest.getResult(QuotesRequest.java:72)
        ... 8 more

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions