Authentication#
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.
Class#
The Auth module, allows you to login to Yahoo! Finance.
|
Auth Sample Code#
The Auth module, allows you to login to Yahoo! Finance.
import yfinance as yf
import os
auth = yf.Auth()
# Set log in cookies from browser
auth.set_login_cookies(os.getenv("COOKIE_T"), os.getenv("COOKIE_Y"))
# Check if the cookies worked
if auth.check_login():
print("Logged in")
else:
print("Invalid cookie")
# Every subsequent request sent to Yahoo Finance will now be under the logged-in user.
# Access user information
auth.user