Connections
Learn how to connect with third-party tools and services in your BDK project.
Implementing Connections
To implement an external connection, define a Python function in your Book class and decorate it with the @connect decorator. This function will act as the connection handler. For OAuth-based connections, refer to OAuth 2.0 Implementation.
Multiple Connections
You can define multiple connections within a Book, each with its own handler method. Use the noun_phrase
keyword argument in the @connect decorator to assign a unique label to each connection and differentiate between authentication methods.
Method Docstrings
In your method docstring, include the following sections in addition to a brief summary:
Arguments: Specify the function's parameters.
Labels: Describe the arguments used for the connection (e.g., API key, credentials). These labels will appear in the UI.
Example
This is an example implementation of connecting to the OpenWeather API using an API key:
OAuth 2.0 Implementation
Open Authorization 2.0 is a widely used authorization framework that provides secure and controlled access to third-party services. BDK supports authentication for Microsoft and Google services.
To implement this authentication flow in your book, the @connect decorator is not required. Instead, apply the @oauth decorator to a Python class and use the @oauthtoken decorator on a handler function to manage tokens.
Example
In this example, the @oauth
decorator configures the OAuth2 flow for Microsoft, specifying endpoints and required scopes. The @oauthtoken
decorator marks the handle_token
method, which processes and stores the access token.
Last updated
Was this helpful?