File: auth

package info (click to toggle)
simplisafe-python 2024.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,268 kB
  • sloc: python: 5,252; sh: 50; makefile: 19
file content (34 lines) | stat: -rwxr-xr-x 861 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/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())