Connections
A connection supplies the credentials used by your App. Define its fields, convert the stored values into credential providers, and validate them with a lightweight authenticated request.
A complete token connection
Section titled “A complete token connection”This example targets an illustrative content service with an HTTPS base URL and a read-only GET /me endpoint. Put the complete block in one C# file in the Setup project. Adapt the endpoint and authentication scheme to your provider.
using System.Net;using System.Net.Http.Headers;using Blackbird.Applications.Sdk.Common.Authentication;using Blackbird.Applications.Sdk.Common.Connections;using Blackbird.Applications.Sdk.Common.Exceptions;
namespace Apps.ContentExample;
public class ConnectionDefinition : IConnectionDefinition{ public IEnumerable<ConnectionPropertyGroup> ConnectionPropertyGroups => [ new() { Name = "API token", AuthenticationType = ConnectionAuthenticationType.Undefined, ConnectionProperties = [ new("base_url") { DisplayName = "API base URL" }, new("api_token") { DisplayName = "API token", Sensitive = true } ] } ];
public IEnumerable<AuthenticationCredentialsProvider> CreateAuthorizationCredentialsProviders(Dictionary<string, string> values) => values.Select(pair => new AuthenticationCredentialsProvider(pair.Key, pair.Value));}
public sealed class ContentClient : IDisposable{ private readonly HttpClient _http = new();
public ContentClient(IEnumerable<AuthenticationCredentialsProvider> credentials) { var values = credentials.ToDictionary(x => x.KeyName, x => x.Value); if (!values.TryGetValue("base_url", out var url) || !Uri.TryCreate(url.TrimEnd('/') + "/", UriKind.Absolute, out var address) || address.Scheme != Uri.UriSchemeHttps) throw new PluginMisconfigurationException("Enter the content service's HTTPS API base URL."); if (!values.TryGetValue("api_token", out var token) || string.IsNullOrWhiteSpace(token)) throw new PluginMisconfigurationException("Enter an API token with permission to read content.");
_http.BaseAddress = address; _http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); }
public Task<HttpResponseMessage> GetIdentityAsync(CancellationToken cancellationToken) => _http.GetAsync("me", cancellationToken);
public void Dispose() => _http.Dispose();}
public class ConnectionValidator : IConnectionValidator{ public async ValueTask<ConnectionValidationResponse> ValidateConnection( IEnumerable<AuthenticationCredentialsProvider> credentials, CancellationToken cancellationToken) { try { using var client = new ContentClient(credentials); using var response = await client.GetIdentityAsync(cancellationToken); return new ConnectionValidationResponse { IsValid = response.IsSuccessStatusCode, Message = response.IsSuccessStatusCode ? "Connected" : response.StatusCode is HttpStatusCode.Unauthorized or HttpStatusCode.Forbidden ? "Check the API token and its read permissions." : "The content service could not validate the connection. Try again later." }; } catch (PluginMisconfigurationException exception) { return new ConnectionValidationResponse { IsValid = false, Message = exception.Message }; } catch (HttpRequestException) { return new ConnectionValidationResponse { IsValid = false, Message = "Could not reach the content service. Check the URL and availability." }; } }}The method name is CreateAuthorizationCredentialsProviders. Keep the connection property keys stable: existing connections store values under those keys.
Credentials in actions and events
Section titled “Credentials in actions and events”In a BaseInvocable subclass, read InvocationContext.AuthenticationCredentialsProviders and pass them to your client. Use a public constructor that accepts InvocationContext. The action example shows the constructor pattern.
Avoid static fields holding connection credentials. Mark secrets as sensitive, keep them out of action outputs, and log operation information rather than authorization headers or tokens.
OAuth connections
Section titled “OAuth connections”For an OAuth provider, define an OAuth connection group and implement IOAuth2AuthorizeService and IOAuth2TokenService. Register these implementations through IApplication.GetInstance<T>(). The authorization service builds the provider URL; the token service exchanges, refreshes, and revokes tokens according to that provider’s contract.
Use the Template App OAuth implementation as a starting point, with your own endpoints, scopes, client configuration, and redirect handling. OAuth is provider-specific; a token connection does not require these services.
Test the connection
Section titled “Test the connection”Use an approved service fixture to check a valid token, a rejected token, an inaccessible account, and a service outage. The validator should return a useful message without exposing credentials. See local testing for the action test harness.