Skip to content

Instantly share code, notes, and snippets.

@virtadpt
Forked from Lana-chan/login.py
Created February 20, 2018 00:53
Show Gist options
  • Save virtadpt/737eeff564fc5612e61c2a3526dc51dc to your computer and use it in GitHub Desktop.
Save virtadpt/737eeff564fc5612e61c2a3526dc51dc to your computer and use it in GitHub Desktop.
interactive script for generating persistent clientcred and usercred files for mastodon.py
#!/usr/bin/python3
# interactive script for generating persistent
# clientcred and usercred files for mastodon.py
from mastodon import Mastodon
from getpass import getpass
import sys
if __name__ == "__main__":
app = input('app name (shows in web): ')
url = input('instance url: ')
email = input('account email: ')
password = getpass('account password: ')
password2 = getpass('repeat password: ')
if password2 != password:
sys.exit('passwords did not match')
Mastodon.create_app(
app,
api_base_url = url,
to_file = 'clientcred.secret'
)
mastodon = Mastodon(
client_id = 'clientcred.secret',
api_base_url = url
)
mastodon.log_in(
email,
password,
to_file = 'usercred.secret'
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment