Emporix Java SDK
A comprehensive Java SDK for integrating with Emporix Commerce APIs.
Prerequisites
Quick start
1
2
Enable the SDK by adding the annotation to your Spring Boot application
import io.emporix.config.EnableEmporixAutoConfiguration;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@EnableEmporixAutoConfiguration // ← Add this
public class MyApplication {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
}3
Configure your credentials
export EMPORIX_TENANT=your-tenant-id
export EMPORIX_API_CREDENTIALS_BACKEND_CLIENT_ID=your-backend-client-id
export EMPORIX_API_CREDENTIALS_BACKEND_SECRET=your-backend-secret
export EMPORIX_API_CREDENTIALS_STOREFRONT_CLIENT_ID=your-storefront-client-id
export EMPORIX_API_CREDENTIALS_STOREFRONT_SECRET=your-storefront-secretemporix:
tenant: your-tenant-id
api:
credentials:
backend:
client-id: your-backend-client-id
secret: your-backend-secret
storefront:
client-id: your-storefront-client-id
secret: your-storefront-secret4
Use the SDK in your code
import io.emporix.auth.service.EmporixTokenService;
import io.emporix.auth.dto.ServiceTokenResponse;
import io.emporix.product.ProductClient;
import io.emporix.product.dto.response.ProductResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ProductService {
@Autowired
private ProductClient productClient;
@Autowired
private EmporixTokenService tokenService;
public List<ProductResponse> getAllProducts() {
// 1. Get service token (with all available scopes)
ServiceTokenResponse token = tokenService.getServiceToken();
// 2. Get Bearer token (null-safe and idempotent)
String authorization = token.bearerAccessToken();
// 3. Call client with authorization
return productClient.getProducts(
null, null, null, 1, 20, "name:asc", true, "en", authorization
).getBody();
}
}Configuration
Property
Required
Default
Description
Environment variables
Enabling the SDK
DTOs only - with no configuration
Full SDK - with auto-configuration
Available services
Product & catalog
Service
Client
Description
Key Operations
Category
Service
Client
Description
Key Operations
Price
Service
Client
Description
Key Operations
Cart & checkout
Service
Client
Description
Key Operations
Order
Service
Client
Description
Key Operations
Customer
Service
Client
Description
Key Operations
Company (B2B)
Service
Client
Description
Key Operations
Shipping
Service
Client
Description
Key Operations
Coupon
Service
Client
Description
Key Operations
Tax
Service
Client
Description
Key Operations
Configuration
Service
Client
Description
Key Operations
Session context
Service
Client
Description
Key Operations
Authentication
Scope constants
Authentication overview
Token Type
Use Case
Credentials Used
How to Obtain
Token caching
Token management
Basic token flow
Using service tokens - backend operations
Using custom credentials
Using anonymous tokens - guest browsing
Using customer tokens - authenticated users
Token cache management
Usage examples
Example 1: Product management
Example 2: Category management
Example 3: Multi-client operations with custom credentials
Example 4: REST controller
Advanced configuration
Custom client beans
ClientConfig options
Custom REST client with timeout
Exception handling
Global exception handler
Manual exception handling
Best practices
Use appropriate scopes
Preserve anonymous tokens on login
Reuse service tokens
Handle errors gracefully
Use custom credentials for integrations and partners
Manage customer tokens in your application
Enable token caching
Troubleshooting
Issue: "Bean of type ProductClient could not be found"
Issue: "401 Unauthorized"
Issue: "Tenant must be configured"
Issue: "Custom credentials 'xxx' not found"
Issue: "403 Forbidden" or "Insufficient Scopes"
Token caching not working
Debugging tips
Last updated
Was this helpful?

