Fetch username from api


#1

I have following code with the help I got some attributes as output and I want to fetch username from output. How can I do that?
Code:
from mastodon import Mastodon
Mastodon.create_app(
‘ooterapp’,
api_base_url = ‘axyz’,
to_file = ‘client.secret’
)

mastodon_var = Mastodon(
client_id = ‘client.secret’,
api_base_url = ‘axyz’
)
mastodon_var.log_in(
‘abc@gmail.com’,
‘abc’,
to_file = ‘user.secret’
)

mastodon_var1 = Mastodon(
client_id = ‘client.secret’,
access_token = ‘user.secret’,
api_base_url = ‘axyz’
)
mastodon.toot(‘Tooting from python using #mastodonpy !’)

output::::

{u’account’: {u’acct’: u’abc’,
u’avatar’: u’abc/avatars/original/missing.png’,
u’avatar_static’: u’abc/avatars/original/missing.png’,
u’created_at’: datetime.datetime(2018, 1, 9, 13, 30, 15, 870000, tzinfo=tzutc()),
u’display_name’: u’’,
u’followers_count’: 27,
u’following_count’: 1,
u’header’: u’abc/headers/original/missing.png’,
u’header_static’: u’abc/headers/original/missing.png’,
u’id’: 2,
u’locked’: False,
u’note’: u’

’,
u’statuses_count’: 2,
u’url’: u’https://member.metastudio.org/@abc’,
u’username’: u’abc’},
u’application’: {u’name’: u’ooterapp’, u’website’: None},
u’content’: u’

hello

’,
u’created_at’: datetime.datetime(2018, 4, 3, 8, 41, 4, 251000, tzinfo=tzutc()),
u’emojis’: [],
u’favourited’: False,
u’favourites_count’: 0,
u’id’:
u’in_reply_to_account_id’: None,
u’in_reply_to_id’: None,
u’language’: u’sr’,
u’media_attachments’: [],
u’mentions’: [],
u’muted’: False,
u’pinned’: False,
u’reblog’: None,
u’reblogged’: False,
u’reblogs_count’: 0,
u’sensitive’: False,
u’spoiler_text’: u’’,
u’tags’: [],
u’uri’: u’abc/users/abc/statuses’,
u’url’: u’abc/@abc/’,

#2

What exactly are you building?


#3

I am building authentication with mastodon.Means login with mastodon feature and for that I want to fetch username. I am almost done with that but I want to fetch username to show it on user’s profile after he logged in with mastodon credentials.


#4

Why don’t you use OAuth and save itself all the trouble?