From 6af01f18c2bb4f641d85d4b3caa00b4e2e842a77 Mon Sep 17 00:00:00 2001 From: clarkzjw Date: Wed, 22 Feb 2023 15:57:02 -0800 Subject: create oauth app before user login --- callback.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'callback.py') diff --git a/callback.py b/callback.py index e7a8308..d2f3ae7 100644 --- a/callback.py +++ b/callback.py @@ -60,7 +60,13 @@ async def process_media_group(context: CallbackContext): async def callback_generate_fedi_login_url(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int: # generate fedi OAuth login url home_instance = update.effective_message.text - mastodon_client = Mastodon(client_id=MASTODON_CLIENT_ID_FILE, api_base_url=home_instance) + client_id, client_secret = Mastodon.create_app( + "Checkin.bot", + scopes=['write:media', 'write:statuses'], + redirect_uris="{}{}".format(BOT_DOMAIN, FEDI_LOGIN_CALLBACK_URL), + api_base_url=home_instance, + ) + mastodon_client = Mastodon(client_id=client_id, client_secret=client_secret, api_base_url=home_instance) oauth_url = mastodon_client.auth_request_url(redirect_uris="{}{}".format(BOT_DOMAIN, FEDI_LOGIN_CALLBACK_URL), scopes=['write:media', 'write:statuses'], state=update.effective_user.id) -- cgit v1.2.3