diff options
author | clarkzjw <[email protected]> | 2023-02-22 15:57:02 -0800 |
---|---|---|
committer | clarkzjw <[email protected]> | 2023-02-23 12:07:32 -0800 |
commit | 6af01f18c2bb4f641d85d4b3caa00b4e2e842a77 (patch) | |
tree | 337cb8f963e3e5367e52d93efceb65539196b8a6 /callback.py | |
parent | ae99c2d7237021e2abb20d4b41a24e0b73028519 (diff) | |
download | swarm2fediverse-6af01f18c2bb4f641d85d4b3caa00b4e2e842a77.tar.gz |
create oauth app before user login
Diffstat (limited to 'callback.py')
-rw-r--r-- | callback.py | 8 |
1 files changed, 7 insertions, 1 deletions
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): | |||
60 | async def callback_generate_fedi_login_url(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int: | 60 | async def callback_generate_fedi_login_url(update: Update, context: ContextTypes.DEFAULT_TYPE) -> int: |
61 | # generate fedi OAuth login url | 61 | # generate fedi OAuth login url |
62 | home_instance = update.effective_message.text | 62 | home_instance = update.effective_message.text |
63 | mastodon_client = Mastodon(client_id=MASTODON_CLIENT_ID_FILE, api_base_url=home_instance) | 63 | client_id, client_secret = Mastodon.create_app( |
64 | "Checkin.bot", | ||
65 | scopes=['write:media', 'write:statuses'], | ||
66 | redirect_uris="{}{}".format(BOT_DOMAIN, FEDI_LOGIN_CALLBACK_URL), | ||
67 | api_base_url=home_instance, | ||
68 | ) | ||
69 | mastodon_client = Mastodon(client_id=client_id, client_secret=client_secret, api_base_url=home_instance) | ||
64 | oauth_url = mastodon_client.auth_request_url(redirect_uris="{}{}".format(BOT_DOMAIN, FEDI_LOGIN_CALLBACK_URL), | 70 | oauth_url = mastodon_client.auth_request_url(redirect_uris="{}{}".format(BOT_DOMAIN, FEDI_LOGIN_CALLBACK_URL), |
65 | scopes=['write:media', 'write:statuses'], | 71 | scopes=['write:media', 'write:statuses'], |
66 | state=update.effective_user.id) | 72 | state=update.effective_user.id) |