Third Party Integration Plugin
Third Party Integration Plugin is a base Plugin Class that is already pre-assigned to HTTPHandler:
@Plugin.for_handler(HttpHandler)
class ThirdPartyIntegrationPlugin(Plugin):As such, when implementing a Plugin that extends the Third Party Integration Plugin, you do not have to assign the handler yourself. Simply create your Plugin as such:
class CustomThirdPartyPlugin(ThirdPartyIntegrationPlugin):
"""This is my custom third party plugin."""
name = "custom_third_party_plugin"
version = "0.0.1"
description = "My awesome third party plugin!"
router: Router
# ...and so on.However, when you extend the Third Party Integration Plugin, there are a few things you need to keep in mind. There are a few important details that we need to implement.
Endpoints
By extending the ThirdPartyIntegrationPlugin, you will expose new endpoints by default in order for users to initiate or create new configuration, as such:
POST /integrations: Used to create or register a new configuration for a particular user. See Authentication to see what kind of input may be possible and how to implement it.POST /integrations/{user_identifier}: Used to select an active configuration. This is only useful for users that have registered more than one account. For example, if a user authorizes two Github accounts, this endpoint can be used to select which account is used for subsequent requests.GET /integration-exists: Used to check whether or not a user has at least one active connection.DELETE /integrations/{user_identifier}: Used to delete an existing integrationGET /success-authorize-callback: Used for OAuth2 only; to confirm the user's authorization and for token exchange with the 3rd party token.
This is used for GL Connectors SDK to retrieve all necessary information.
Authentication
If the method defining the authentication is not defined or not supported (e.g., SQL Plugin does not support OAuth2 or Plugins that do not support BYOK or custom configuration), it is expected for you to raise NotImplementedError("...") in order to inform the client that this authentication method is not supported.
Each plugin may not have to support all methods of creating authentication, but it is recommended to implement at least one (unless your Plugin is entirely unauthenticated).
OAuth2
Required methods to implement:
initialize_authorization: Used to create a URL for users to follow for OAuth2.success_authorize_callback: Used to exchange token with 3rd party integration when the user successfully authorizes for OAuth2.
OAuth2 is a way for the user to authorize a user using third party login directly. This way, there needs to be two steps in order to fully authenticate and get the appropriate token, following this sequence diagram:

GL Connectors OAuth2 Flow. Mermaid Link.
As such, you need to implement the two methods in order to fully achieve authentication. A simple example would look like this:
As you can see, during initialize_authorization, it's just an initialization; we do not create the integration yet. The one who creates the integration is actually the success_authorize_callback function. Here is an example of how one would implement the success_authorize_callback function:
Custom Configuration
Required methods to implement:
initialize_custom_configuration: Used to immediately register and store a configuration based on user-provided keys.
Custom configuration is a way for us to set a third party integration when the user has either custom configuration (e.g., custom endpoint URL, custom API) or a custom key (BYOK). The following code shows the simplest way to implement a custom configuration based on the configuration entry. Because it is a free-form input, you are responsible for handling unexpected values and keys.
Multiple Integrations
Required methods to implement:
user_has_integrationselect_integrationremove_integrationget_integrationuser_has_integration
To support multiple integrations, we need to implement the four methods defining multiple integration. They typically have the same implementation as such. You normally don't need to change anything of the default implementation, as such:
Combining it all
An example fully-functional Third Party Integration Handler will look something like this (private methods not included):
Last updated