#!/usr/bin/env python3 import json from mastodon import Mastodon scopes = ["read:statuses", "read:accounts", "read:follows", "write:statuses", "read:notifications"] cfg = json.load(open('config.json', 'r')) if "client" not in cfg: print("No client credentials, registering application") client_id, client_secret = Mastodon.create_app("lynnegle-assistant", api_base_url=cfg['site'], scopes=scopes, website="https://git.lynnesbian.space/lynnesbian/lynnegle-assistant") cfg['client'] = { "id": client_id, "secret": client_secret } if "secret" not in cfg: print("No user credentials, logging in") client = Mastodon(client_id = cfg['client']['id'], client_secret = cfg['client']['secret'], api_base_url=cfg['site']) print("Open this URL: {}".format(client.auth_request_url(scopes=scopes))) cfg['secret'] = client.log_in(code=input("Secret: "), scopes=scopes) json.dump(cfg, open("config.json", "w+"))