Overview
TheSalesforceAuthResponse struct encapsulates all the authentication data returned by Salesforce after successful OAuth 2.0 authentication. This includes access tokens, instance information, and security signatures for secure API communication.
Definition
Properties
Access token that acts as a session ID for making API requests. This is the primary authentication credential used for all Salesforce API calls. The token should be treated as sensitive data and stored securely.
Identifies the Salesforce instance for API calls. The base URL for all Salesforce API endpoints. This is specific to your Salesforce organization and may change between environments.
Identity URL for user identification and information queries. Contains user and organization identification information that can be used to retrieve additional user metadata and permissions.
Token type (typically “Bearer”). Indicates the type of authentication token. For Salesforce OAuth 2.0, this is typically “Bearer” and is used in Authorization headers.
When the signature was created (Unix epoch seconds). Timestamp indicating when the authentication response was created. Used for security validation and replay protection.
Base64-encoded HMAC-SHA256 signature. Cryptographic signature for verifying the authenticity of the response. Used for security validation and preventing tampering.
JSON Mapping
The struct uses custom coding keys to map OAuth 2.0 standard field names:access_token→accessTokeninstance_url→instanceUrlid→idtoken_type→tokenTypeissued_at→issuedAtsignature→signature
Usage Example
Integration with CongregationKit
Security Considerations
Token Security
- Secure Storage: Store access tokens securely, never in plain text
- Token Expiration: Monitor token expiration and refresh as needed
- Scope Limitation: Use minimal required OAuth scopes
- HTTPS Only: Always use HTTPS for token transmission
Signature Verification
- Timestamp Validation: Verify
issuedAttimestamp is recent - Signature Verification: Validate HMAC-SHA256 signature when possible
- Replay Protection: Check for duplicate requests using timestamps
Data Validation
- Required Fields: All fields are required for valid authentication
- URL Validation: Instance URL must be valid HTTPS URL
- Token Format: Access token must be non-empty string
- Timestamp Format: Issued at timestamp must be valid Unix timestamp
