Skip to main content

Update API Authentication Configuration

Used to update the authentication configuration for an API tool. This endpoint allows you to configure various authentication methods including API tokens, OAuth2, basic authentication, and custom headers.

API Endpoint

PropertyValue
Request MethodPOST
Request URLhttps://api.seliseblocks.com/tools/api-auth-config/{tool_id}

Request

Request Example

curl -X POST 'https://api.seliseblocks.com/tools/api-auth-config/tool_weather_api' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"auth_config": {
"AuthType": "api_key",
"APIToken": "your_api_token_here",
"AuthKeyLocation": "header",
"AuthKeyName": "X-API-Key",
"AuthKeyPrefix": "",
"Username": null,
"Password": null,
"OAuth2Config": null,
"CustomHeaders": {
"User-Agent": "MyApp/1.0"
},
"CustomQueryParams": {}
},
"headers": {
"Content-Type": "application/json",
"Accept": "application/json"
},
"project_key": "YOUR_PROJECT_KEY"
}'

Request Headers

FieldTypeRequiredDescription
acceptstringYesAccepted response format. Use application/json
Content-Typeapplication/jsonYesData type, must be application/json.

Path Parameters

FieldTypeRequiredDescription
tool_idstringYesUnique identifier of the API tool to configure authentication for.

Request Body

Request Body Schema

{
"auth_config": {
"AuthType": "none",
"APIToken": "string",
"AuthKeyLocation": "header",
"AuthKeyName": "string",
"AuthKeyPrefix": "string",
"Username": "string",
"Password": "string",
"OAuth2Config": {
"ClientID": "string",
"ClientSecret": "string",
"TokenURL": "string",
"Scopes": ["string"],
"RefreshToken": "string",
"AccessToken": "string",
"TokenExpiresAt": "2026-01-11T13:31:52.680Z",
"GrantType": "client_credentials",
"AuthorizationEndpoint": "string",
"RedirectURI": "string",
"PKCEConfig": {
"CodeVerifier": "string",
"CodeChallenge": "string",
"CodeChallengeMethod": "S256"
},
"State": "string",
"Nonce": "string"
},
"CustomHeaders": {},
"CustomQueryParams": {}
},
"headers": {},
"project_key": "string"
}

Request Body Parameters

FieldTypeRequiredDescription
auth_configobjectYesAuthentication configuration object.
headersobjectNoDefault headers to include in all API requests.
project_keystringYesThe project key for your project.

Authentication Configuration Fields

FieldTypeDescription
AuthTypestringType of authentication (none, api_key, basic, bearer, oauth2).
APITokenstringAPI token/key for authentication.
AuthKeyLocationstringLocation of auth key (header, query).
AuthKeyNamestringName of the authentication key/header.
AuthKeyPrefixstringPrefix for the auth value (e.g., "Bearer ", "Token ").
UsernamestringUsername for basic authentication.
PasswordstringPassword for basic authentication.
OAuth2ConfigobjectOAuth2 configuration object (see below).
CustomHeadersobjectCustom headers to include in requests.
CustomQueryParamsobjectCustom query parameters to include in requests.

OAuth2 Configuration Fields

FieldTypeDescription
ClientIDstringOAuth2 client ID.
ClientSecretstringOAuth2 client secret.
TokenURLstringURL to obtain access tokens.
ScopesarrayArray of OAuth2 scopes to request.
RefreshTokenstringRefresh token for obtaining new access tokens.
AccessTokenstringCurrent access token.
TokenExpiresAtstringISO 8601 timestamp when the access token expires.
GrantTypestringOAuth2 grant type (client_credentials, authorization_code, password).
AuthorizationEndpointstringAuthorization endpoint URL (for authorization_code flow).
RedirectURIstringRedirect URI for OAuth2 callback.
PKCEConfigobjectPKCE configuration for enhanced security.
StatestringState parameter for CSRF protection.
NoncestringNonce value for additional security.

PKCE Configuration Fields

FieldTypeDescription
CodeVerifierstringCode verifier for PKCE.
CodeChallengestringCode challenge derived from verifier.
CodeChallengeMethodstringMethod used for code challenge (S256, plain).

Authentication Types

1. No Authentication

{
"auth_config": {
"AuthType": "none"
},
"project_key": "YOUR_PROJECT_KEY"
}

2. API Key Authentication (Header)

{
"auth_config": {
"AuthType": "api_key",
"APIToken": "your_api_token_here",
"AuthKeyLocation": "header",
"AuthKeyName": "X-API-Key",
"AuthKeyPrefix": ""
},
"project_key": "YOUR_PROJECT_KEY"
}

3. Bearer Token Authentication

{
"auth_config": {
"AuthType": "bearer",
"APIToken": "your_bearer_token_here",
"AuthKeyLocation": "header",
"AuthKeyName": "Authorization",
"AuthKeyPrefix": "Bearer "
},
"project_key": "YOUR_PROJECT_KEY"
}

4. Basic Authentication

{
"auth_config": {
"AuthType": "basic",
"Username": "your_username",
"Password": "your_password"
},
"project_key": "YOUR_PROJECT_KEY"
}

5. OAuth2 Client Credentials

{
"auth_config": {
"AuthType": "oauth2",
"OAuth2Config": {
"ClientID": "your_client_id",
"ClientSecret": "your_client_secret",
"TokenURL": "https://auth.example.com/oauth/token",
"GrantType": "client_credentials",
"Scopes": ["read", "write"]
}
},
"project_key": "YOUR_PROJECT_KEY"
}

6. OAuth2 Authorization Code with PKCE

{
"auth_config": {
"AuthType": "oauth2",
"OAuth2Config": {
"ClientID": "your_client_id",
"ClientSecret": "your_client_secret",
"TokenURL": "https://auth.example.com/oauth/token",
"AuthorizationEndpoint": "https://auth.example.com/oauth/authorize",
"RedirectURI": "https://yourapp.com/callback",
"GrantType": "authorization_code",
"Scopes": ["read", "write"],
"PKCEConfig": {
"CodeVerifier": "generated_code_verifier",
"CodeChallenge": "generated_code_challenge",
"CodeChallengeMethod": "S256"
},
"State": "random_state_string"
}
},
"project_key": "YOUR_PROJECT_KEY"
}

Response

Success Response (200 OK)

Returns an object containing the authentication configuration update status.

{
"is_success": true,
"item_id": "tool_weather_api",
"detail": "API authentication configuration updated successfully",
"error": {}
}

Response Fields

FieldTypeDescription
is_successbooleanIndicates whether the operation was successful.
item_idstringUnique identifier of the tool that was configured.
detailstringSuccess or failure message with additional context.
errorobjectError details if the operation failed (empty if successful).

Error Response (422 Unprocessable Entity)

Returns validation error details when the request body is invalid.

{
"detail": [
{
"loc": [
"body",
"auth_config",
"AuthType"
],
"msg": "invalid authentication type",
"type": "value_error.str.regex"
}
]
}

Error Response Fields

FieldTypeDescription
detailarrayArray of validation error objects.
locarrayLocation of the error in the request (e.g., path, body).
msgstringHuman-readable error message.
typestringError type identifier.

Error Codes

Status CodeDescriptionResponse Type
200Successful ResponseSuccess
400Bad Request - Invalid authentication configBad Request
404Not Found - Tool does not existNot Found
422Validation Error - Invalid request parametersUnprocessable Entity
warning

Security Best Practices

  • Never expose credentials: Store API keys, tokens, and secrets securely
  • Use HTTPS: Always use HTTPS for API endpoints requiring authentication
  • Rotate credentials: Regularly rotate API keys and tokens
  • Least privilege: Request only the OAuth2 scopes necessary for your use case
  • Token expiration: Implement proper token refresh logic for OAuth2
  • PKCE for public clients: Always use PKCE for OAuth2 authorization code flow in public clients
  • Validate tokens: Implement token validation on the server side
  • Monitor access: Log and monitor API authentication attempts
tip

Authentication Type Selection

  • none: For public APIs that don't require authentication
  • api_key: For simple API key-based authentication
  • bearer: For JWT tokens or similar bearer token schemes
  • basic: For username/password authentication (use with HTTPS only)
  • oauth2: For secure, delegated access with token refresh capabilities

Custom Headers and Query Parameters Use CustomHeaders and CustomQueryParams to add additional authentication-related headers or parameters required by specific APIs (e.g., API version headers, client identifiers).