doc/source/reference/yfinance.auth.rst
.. currentmodule:: yfinance
.. note::
The Auth module cannot automate login using a username and password
because Yahoo Finance requires solving a reCAPTCHA, which blocks automation.
You must manually obtain and set the authentication cookies.
The Auth module lets you log in to Yahoo! Finance, check the login state and
read the account's subscription tier.
.. autosummary:: :toctree: api/
Auth
Logging in with browser cookies, then checking the login state and subscription tier:
.. literalinclude:: examples/auth.py :language: python
To authenticate with Yahoo Finance, you need to obtain specific cookies. Follow these steps:
.. rubric:: Steps to Obtain the Cookies
Open your browser (e.g., Chrome, Firefox).
Log in to Yahoo Finance <https://finance.yahoo.com>_.
Open the browser's Developer Tools:
F12 or Ctrl + Shift + I (Windows/Linux)Cmd + Option + I (Mac)Navigate to the Application tab (Chrome) or Storage tab (Firefox).
In the Cookies section, select https://finance.yahoo.com.
Locate the cookies named T and Y.
Copy the values of these cookies and pass them to the authentication function.