ranaroussi / yfinance

Download market data from Yahoo! Finance's API
https://aroussi.com/post/python-yahoo-finance
Apache License 2.0
14.93k stars 2.45k forks source link

401 Client Error: Unauthorized for url: #1952

Open KingTurbo opened 6 months ago

KingTurbo commented 6 months ago

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

SC8198 commented 6 months ago

Having same issues.

Operating system Linux

Region: USA

yfinance version 0.2.40

justmessingaround commented 6 months ago

Same issue also.

apenake commented 6 months ago

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

stan-artemyev commented 6 months ago

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

GongXiangbo commented 6 months ago

Same issue - worked fine few hours ago

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

gustavph commented 6 months ago

Same issue - worked last week

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

jrkong commented 6 months ago

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

fpsy commented 6 months ago

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

justmessingaround commented 5 months ago

its randomly back working for me too