bachya/simplisafe-python

View on GitHub
script/auth

Summary

Maintainability
Test Coverage
#!/usr/bin/env python
"""Initiate the SimpliSafe authorization process."""

import asyncio
import sys
import webbrowser

from simplipy.util.auth import (
    get_auth0_code_challenge,
    get_auth0_code_verifier,
    get_auth_url,
)


async def main() -> None:
    """Run."""
    code_verifier = get_auth0_code_verifier()
    code_challenge = get_auth0_code_challenge(code_verifier)
    auth_url = get_auth_url(code_challenge)

    try:
        input("Press <ENTER> to be taken to the SimpliSafe login page... ")
    except KeyboardInterrupt:
        sys.exit(1)

    webbrowser.open(auth_url)

    auth_code = input("Enter the code received from the SimpliSafe auth webpage: ")
    print()
    print("You are now ready to use the SimpliSafe API!")
    print(f"Authorization Code: {auth_code}")
    print(f"Code Verifier: {code_verifier}")


asyncio.run(main())