From 9c60bc8ce4a0990c228d2cd746791b88c41532b8 Mon Sep 17 00:00:00 2001 From: ConfuSomu Date: Thu, 24 Aug 2023 18:43:15 -0400 Subject: Implement basic Mastodon API support Implement support for OAuth 2.0 code entry, which is then used to retrieve a token that is stored in the application's settings. Authentification allowed the implementation of a basic "get post from URL" feature mostly made for testing. --- src/net/instance.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/net/instance.h (limited to 'src/net/instance.h') diff --git a/src/net/instance.h b/src/net/instance.h new file mode 100644 index 0000000..2b7eec7 --- /dev/null +++ b/src/net/instance.h @@ -0,0 +1,24 @@ +#pragma once +#include "src/activitypub/appost.h" +#include "src/settings_interface.h" + +class Instance { +public: + struct OAuth2Step2 { + bool ok; + QString token; + }; + + virtual ~Instance() {}; + virtual APPost* get_post_from_url(const QString &url) = 0; + // Returns the URI the user has to visit in their browser + virtual QString oauth2_step1(); + // auth_code is the code given by the user through the URI + // Returns true if authenfication was successful. + virtual OAuth2Step2 oauth2_step2(const QString &auth_code); + bool supports_oauth2 = false; + // Creates an instance by reading the type from settings + static Instance* create_instance(); + // Creates a specific type of instance, for use with SettingsDialog + static Instance* create_instance(AppSettingsTypes::InstanceType type); +}; -- cgit v1.2.3-54-g00ecf