Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Log into beam though the API
- """
- #!/usr/bin/python3.4
- from getpass import getpass
- from requests import Session
- from beam_interactive import start, proto
- URL = "https://beam.pro/api/v1/"
- URL_LOGIN = "/users/login"
- URL_INTERACIVE = "/interactive/{channel}/robot"
- S = Session()
- USE_2FA = False
- AUTHENTICATION = {
- "username": "",
- "password": "!",
- "code": "" # Unnecessary if two-factor authentication is disabled.
- }
- '''
- AUTHENTICATION['username'] = input("Username : ")
- AUTHENTICATION['password'] = getpass("Password : ")
- if USE_2FA:
- while not ((len(AUTHENTICATION['code']) == 6) or
- any(c.isalpha() for c in AUTHENTICATION['code'])):
- AUTHENTICATION['code'] = input("2FA code : ")
- if (len(AUTHENTICATION['code']) < 6) or (len(AUTHENTICATION['code']) > 6):
- print("ERROR: 2FA Code must be 6 characters long")
- if any(c.isalpha() for c in AUTHENTICATION['code']):
- print("ERROR: 2FA Code MUST NOT contain letters or special characters")
- '''
- def login(username, password, code='', *, session=S):
- """Log into Beam via the API."""
- auth = dict(username=username, password=password, code=code)
- return session.post(URL + URL_LOGIN, data=auth).json
- channel_id = login('skynet', 'Gordon60', '')["channel"]["id"]
- print(channel_id)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement