How to authenticate custom adapter requests
Authenticate with a Username and Password
Field
Type
import requests
class CustomAdapter(BaseAdapter):
def execute(self, request):
response = AdapterResponse()
response.success = False
try:
r = requests.request(
method=request.payload.get("method", "GET"),
url=f"{self.config['base_url']}{request.payload.get('path', '')}",
auth=(self.config["username"], self.config["password"]),
json=request.payload.get("body"),
timeout=self.config.get("timeout", 30),
)
r.raise_for_status()
response.payload = r.json()
response.success = True
except Exception as e:
response.add_message_and_stack_trace(MessageTypes.UNCATEGORIZED_ERROR, str(e))
return response
def validate_config(self):
if not self.config.get("username") or not self.config.get("password"):
raise Exception("username and password are required")Authenticate with an API Key or Token
Field
Type
Authenticate with OAuth Client Credentials
Field
Type
Notes
Last updated
Was this helpful?