yfinance icon indicating copy to clipboard operation
yfinance copied to clipboard

401 Client Error: Unauthorized for url:

Open KingTurbo opened this issue 1 year ago • 9 comments

Describe bug

An issue occurs when attempting to fetch stock information using the yfinance library. The request results in a 401 Client Error: Unauthorized.

import yfinance as yf

msft = yf.Ticker("MSFT")

get all stock info

msft.info

401 Client Error: Unauthorized for url: https://query2.finance.yahoo.com/v10/finance/quoteSummary/MSFT?modules=financialData%2CquoteType%2CdefaultKeyStatistics%2CassetProfile%2CsummaryDetail&corsDomain=finance.yahoo.com&formatted=false&symbol=MSFT&crumb=2abgHhN2kUC

Environment:

Operating System: Windows 10, Windows 11 Region: Europe both current yfinance version

Simple code that reproduces your problem

import yfinance as yf

msft = yf.Ticker("MSFT")

get all stock info

msft.info

Debug log

...

Bad data proof

No response

yfinance version

0.2.40

Python version

Python 3.11.4

Operating system

W10/11

KingTurbo avatar May 29 '24 20:05 KingTurbo

Having same issues.

Operating system Linux

Region: USA

yfinance version 0.2.40

SC8198 avatar May 29 '24 21:05 SC8198

Same issue also.

justmessingaround avatar May 29 '24 22:05 justmessingaround

Same issue - worked fine a few days ago. Upgrading yfinance does not solve: OS: Mac 13.2.1 Region: USA Python: 3.11.4 yfinance: 0.2.40

apenake avatar May 29 '24 22:05 apenake

Same issue - worked earlier today. OS: Mac 14.5 Python: 3.12.3 yfinance: latest 0.2.40

stan-artemyev avatar May 29 '24 22:05 stan-artemyev

Same issue - worked fine few hours ago

OS: Windows 11 Region: Italy Python: 3.12.3 yfinance: 0.2.40

GongXiangbo avatar May 29 '24 22:05 GongXiangbo

Same issue - worked last week

OS: Windows 11 Region: Brazil Python: 3.12 yfinance: 0.2.40

gustavph avatar May 29 '24 22:05 gustavph

The issue ties back to the crumb. It's likely Yahoo changed something with their cookies or how they expect to receive the crumb.

jrkong avatar May 30 '24 00:05 jrkong

I had the same issue yesterday, but now it works again.

fpsy avatar May 30 '24 06:05 fpsy

its randomly back working for me too

justmessingaround avatar May 30 '24 08:05 justmessingaround