Auth#

class yfinance.Auth(session=None)#

Attributes

user

Get the logged-in user’s details.

Returns:

A dictionary containing the user’s details if logged in, or None if not logged in.

Return type:

dict | None

Methods

__init__(session=None)
check_login() bool

Check whether the user is logged in to Yahoo Finance.

set_login_cookies(cookie_t: str, cookie_y: str) None

Set the login cookies to indicate that the user is logged in.

How to Obtain the Cookies:
  1. Open your browser (e.g., Chrome, Firefox).

  2. Log in to Yahoo Finance (https://finance.yahoo.com).

  3. Open the browser’s Developer Tools: Press F12 or Ctrl + Shift + I (Windows/Linux) or Cmd + Option + I (Mac).

  4. Go to the “Application” tab (Chrome) or “Storage” tab (Firefox).

  5. In the “Cookies” section, select https://finance.yahoo.com.

  6. Look for the cookies named T and Y.

  7. Copy the values of these cookies and pass them to this function.

Parameters:
  • cookie_t (str) – The value for the ‘T’ cookie.

  • cookie_y (str) – The value for the ‘Y’ cookie.

check_login() bool#

Check whether the user is logged in to Yahoo Finance.

set_login_cookies(cookie_t: str, cookie_y: str) None#

Set the login cookies to indicate that the user is logged in.

How to Obtain the Cookies:
  1. Open your browser (e.g., Chrome, Firefox).

  2. Log in to Yahoo Finance (https://finance.yahoo.com).

  3. Open the browser’s Developer Tools: Press F12 or Ctrl + Shift + I (Windows/Linux) or Cmd + Option + I (Mac).

  4. Go to the “Application” tab (Chrome) or “Storage” tab (Firefox).

  5. In the “Cookies” section, select https://finance.yahoo.com.

  6. Look for the cookies named T and Y.

  7. Copy the values of these cookies and pass them to this function.

Parameters:
  • cookie_t (str) – The value for the ‘T’ cookie.

  • cookie_y (str) – The value for the ‘Y’ cookie.