Authentication overview
HelloSign API authentication is fundamental for securely interacting with the HelloSign platform, allowing applications to programmatically create, send, and manage e-signature requests. The API employs standard authentication protocols to ensure that only authorized clients can access resources and perform actions on behalf of users or applications. Choosing the appropriate authentication method depends on the application's architecture, whether it's a server-side service, a client-side application, or a third-party integration that requires user consent.
Proper implementation of authentication not only safeguards sensitive document workflows but also ensures compliance with various regulatory standards that govern electronic signatures, such as the ESIGN Act and eIDAS. HelloSign API's authentication mechanisms are designed to integrate seamlessly into existing development environments, supported by client libraries across multiple programming languages including Python, Ruby, PHP, and Node.js, which abstract away much of the underlying complexity of handling authentication headers and token management.
Developers should consult the official HelloSign API documentation for the most up-to-date and detailed guidance on implementing each authentication flow. Adhering to the specified protocols helps maintain the integrity and confidentiality of all e-signature transactions processed through the API.
Supported authentication methods
HelloSign API supports two primary authentication methods tailored for different integration scenarios: API Key authentication and OAuth 2.0. Each method offers distinct advantages regarding security, ease of implementation, and the scope of access it grants.
1. API Key Authentication
API Key authentication is a straightforward method suitable for server-side applications where direct user interaction for authorization is not required. Developers generate a unique API key from their HelloSign account dashboard, which then acts as a permanent credential to authenticate API requests. This method provides full access to the HelloSign account's resources without explicit user consent for each action, making it ideal for automated workflows and backend services.
When using API keys, the key is typically passed in the Authorization header of HTTP requests or as a query parameter. It is crucial to treat API keys as sensitive credentials due to the broad access they provide. Compromised API keys can lead to unauthorized access to your HelloSign account and its functionalities.
2. OAuth 2.0
OAuth 2.0 is an authorization framework that enables third-party applications to obtain limited access to an HTTP service, either on behalf of a resource owner (e.g., a HelloSign user) or by orchestrating an interaction between the resource owner and the HTTP service. This method is more secure and flexible for client-side applications, mobile apps, or integrations where user consent is required to access their HelloSign data. OAuth 2.0 grants application-specific permissions without exposing user credentials directly to the third-party application.
HelloSign's OAuth 2.0 implementation typically follows the Authorization Code Grant flow, which involves several steps:
- The application redirects the user to HelloSign's authorization server.
- The user grants permission to the application.
- HelloSign redirects the user back to the application with an authorization code.
- The application exchanges the authorization code for an access token and optionally a refresh token.
- The application uses the access token to make API requests on behalf of the user.
Access tokens are typically short-lived, and refresh tokens can be used to obtain new access tokens without requiring the user to re-authorize. This enhances security by limiting the window of opportunity for token misuse. For a comprehensive understanding of OAuth 2.0 flows, the OAuth 2.0 documentation provides detailed specifications.
The following table summarizes the key characteristics of each authentication method:
| Method | When to Use | Security Level | Credential Type |
|---|---|---|---|
| API Key | Server-side applications, backend services, automated workflows needing full account access. | Medium (requires careful handling of keys) | Single API Key |
| OAuth 2.0 | Client-side applications, mobile apps, third-party integrations requiring user consent and granular permissions. | High (token-based, user-consented, limited scope) | Client ID, Client Secret, Access Token, Refresh Token |
Getting your credentials
Before making authenticated requests to the HelloSign API, you need to obtain the necessary credentials from your HelloSign account. The process varies slightly depending on whether you opt for API Key authentication or OAuth 2.0.
For API Key Authentication:
- Log in to HelloSign: Access your HelloSign account.
- Navigate to API Settings: Go to the "Integrations" or "API" section in your account settings. The exact path may vary, but typically it's under settings or developer options.
- Generate API Key: Look for an option to generate a new API key. You might be prompted to provide a label for your key for organizational purposes.
- Copy and Secure Your Key: Once generated, the API key will be displayed. Copy it immediately and store it securely. For security reasons, HelloSign typically only shows the full API key once upon generation. If you lose it, you may need to revoke it and generate a new one.
For detailed, step-by-step instructions, refer to the HelloSign API Keys documentation.
For OAuth 2.0:
- Create an API App: Within your HelloSign account's API settings, you'll need to create an "API App" or "Client Application."
- Configure App Details: Provide details such as your application's name, description, and crucial for OAuth, the Redirect URIs (Callback URLs). These are the URLs to which HelloSign will redirect the user after they authorize your application. Ensure these URLs are correctly configured and match the URLs in your application's code.
- Obtain Client ID and Client Secret: Upon creating your API App, HelloSign will provide you with a unique Client ID and Client Secret. The Client ID is public, but the Client Secret must be kept confidential as it authenticates your application to HelloSign's authorization server.
- Set Scopes: Define the permissions (scopes) your application requires from the user (e.g.,
request_signature,read_account). This ensures your application only requests necessary access.
Refer to the HelloSign OAuth documentation for precise configuration steps and best practices for securing your Client Secret.
Authenticated request example
This example demonstrates how to make an authenticated request using an API key in Python, one of the languages supported by the HelloSign API client libraries. The principle of including the API key in the request header is similar across other programming languages and SDKs.
Using an API Key (Python SDK)
First, ensure you have the HelloSign Python SDK installed (pip install hellosign-sdk).
import hellosign_sdk
# Replace with your actual API key
API_KEY = "YOUR_HELLOSIGN_API_KEY"
# Initialize the API client
client = hellosign_sdk.HSClient(api_key=API_KEY)
try:
# Example: Get account information
account = client.get_account()
print(f"Account ID: {account.account_id}")
print(f"Email Address: {account.email_address}")
# Example: Create a new signature request (simplified for demonstration)
# For a real signature request, you would need to specify signers, files, etc.
# response = client.send_signature_request(
# test_mode=True,
# title="My Document",
# subject="Please sign this document",
# message="Attached is the document for your signature.",
# signers=[{"email_address": "[email protected]", "name": "Signer Name"}],
# files=["/path/to/your/document.pdf"]
# )
# print(f"Signature request sent with ID: {response.signature_request_id}")
except hellosign_sdk.errors.HSException as e:
print(f"API Error: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")
Using OAuth 2.0 (Conceptual Example)
While a full OAuth 2.0 implementation is more complex and involves multiple redirects and token exchanges, here's a conceptual outline of how an OAuth-authenticated request might look after obtaining an access token:
import hellosign_sdk
# Assume you have obtained an access token via the OAuth flow
ACCESS_TOKEN = "YOUR_OBTAINED_ACCESS_TOKEN"
# Initialize the API client with the access token
# The SDK typically handles setting the Authorization header correctly
client = hellosign_sdk.HSClient(oauth_token=ACCESS_TOKEN)
try:
# Example: Get account information using the OAuth token
# This will fetch the account associated with the user who granted the token
account = client.get_account()
print(f"Account ID: {account.account_id}")
print(f"Email Address: {account.email_address}")
except hellosign_sdk.errors.HSException as e:
print(f"API Error: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")
The HelloSign SDKs abstract away much of the HTTP request boilerplate, allowing developers to focus on application logic. For complete code examples and detailed usage, refer to the HelloSign SDK documentation.
Security best practices
Securing your HelloSign API integration is paramount to protect sensitive documents and user data. Adhering to these best practices will help mitigate common security risks:
- Keep API Keys and Client Secrets Confidential:
- Never hardcode: Avoid embedding API keys or client secrets directly into your source code.
- Environment variables: Store credentials in environment variables or a secure configuration management system.
- Access control: Restrict access to these credentials to only the necessary personnel and systems.
- Version control: Exclude credential files from version control systems (e.g., using
.gitignore).
- Use OAuth 2.0 for User-Facing Applications:
- For applications that operate on behalf of users, OAuth 2.0 is the preferred method as it avoids handling user credentials directly and allows for granular permission control.
- Implement the Authorization Code Grant flow securely, ensuring your redirect URIs are strictly validated.
- Implement Least Privilege:
- When configuring an API key or an OAuth application, request or enable only the minimum necessary permissions (scopes) required for your application to function. This limits the potential damage if credentials are compromised.
- Regularly Rotate API Keys:
- Periodically generate new API keys and revoke old ones. This practice reduces the window of opportunity for a compromised key to be exploited.
- Secure Your Callback URLs (Redirect URIs):
- For OAuth 2.0, ensure that your registered Redirect URIs are specific and secured with HTTPS. Avoid using wildcard URIs or insecure HTTP endpoints, as these can be exploited in redirection attacks.
- Validate Webhooks:
- If your application uses HelloSign webhooks for real-time updates, always validate the authenticity of incoming webhook requests. HelloSign provides a signature in the request header (
X-HelloSign-Signature) that you can use to verify the payload's integrity and origin. This prevents spoofed requests. For more details on this, consult the HelloSign webhook security guide.
- If your application uses HelloSign webhooks for real-time updates, always validate the authenticity of incoming webhook requests. HelloSign provides a signature in the request header (
- Monitor API Usage:
- Regularly review your API usage logs for any unusual activity that might indicate unauthorized access or misuse of your credentials. Implement alerting for suspicious patterns.
- Use HTTPS Everywhere:
- Always ensure all communications with the HelloSign API are conducted over HTTPS to encrypt data in transit and protect against man-in-the-middle attacks. HelloSign API endpoints exclusively use HTTPS.
- Error Handling and Logging:
- Implement robust error handling for authentication failures and log relevant (non-sensitive) details for auditing and debugging purposes. Avoid exposing sensitive information in error messages.
By integrating these security best practices into your development and operational workflows, you can significantly enhance the security posture of your HelloSign API integration and protect both your application and your users.