Skip to content

Instantly share code, notes, and snippets.

@lovie
Last active January 10, 2026 23:49
Show Gist options
  • Select an option

  • Save lovie/82962d64afd13cd4b1b5e7b5f9a5db08 to your computer and use it in GitHub Desktop.

Select an option

Save lovie/82962d64afd13cd4b1b5e7b5f9a5db08 to your computer and use it in GitHub Desktop.
Fetch Blink tokens for a workaround for auth with homebridge-blink-for-home-new
import asyncio
from aiohttp import ClientSession
from blinkpy.blinkpy import Blink
from blinkpy.auth import Auth, BlinkTwoFARequiredError
USERNAME = "[email protected]"
PASSWORD = "***"
TOKENS_FILE = "tokens.txt"
async def start():
async with ClientSession() as session:
blink = Blink(session=session)
# no_prompt = True as per your requirement
auth = Auth(
{
"username": USERNAME,
"password": PASSWORD,
},
no_prompt=True,
)
blink.auth = auth
try:
await blink.start()
except BlinkTwoFARequiredError:
# YOU handle OTP input manually
otp = input("Enter Blink OTP: ").strip()
await blink.prompt_2fa()
# Persist tokens
await blink.save(TOKENS_FILE)
print(f"Tokens saved to {TOKENS_FILE}")
return blink
if __name__ == "__main__":
asyncio.run(start())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment