401 Client Error: Unauthorized for url:
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
Having same issues.
Operating system Linux
Region: USA
yfinance version 0.2.40
Same issue also.
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
Same issue - worked earlier today. OS: Mac 14.5 Python: 3.12.3 yfinance: latest 0.2.40
Same issue - worked fine few hours ago
OS: Windows 11 Region: Italy Python: 3.12.3 yfinance: 0.2.40
Same issue - worked last week
OS: Windows 11 Region: Brazil Python: 3.12 yfinance: 0.2.40
The issue ties back to the crumb. It's likely Yahoo changed something with their cookies or how they expect to receive the crumb.
I had the same issue yesterday, but now it works again.
its randomly back working for me too