Skip to content

Instantly share code, notes, and snippets.

@Lana-chan
Created February 19, 2018 22:27
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Lana-chan/b0d937968d22eca6dcd79a0524449f1d to your computer and use it in GitHub Desktop.
Save Lana-chan/b0d937968d22eca6dcd79a0524449f1d 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