Initialization

ET

  • API Reference
    • API function release records
    • Appendix
    • Common Request Headers and Response Headers
    • Dedicated Line Related Interfaces
      • Add dedicated channel routing parameters
      • Add dedicated channel user object
      • Apply for physical dedicated line
      • Associate dedicated channel
      • Create dedicated channel
      • Create routing rules of Dedicated channel
      • Delete dedicated channel
      • Delete routing rules of dedicated channel
      • Disable dedicated channel IPv6 function
      • Disassociate dedicated channel
      • Enable IPv6 function for the dedicated channel
      • Modify the dedicated channel routing rules
      • Query dedicated channel
      • Query dedicated line details
      • Query dedicated line list
      • Query the routing rules of the dedicated channel
      • Remove dedicated channel route parameters
      • Remove dedicated channel user object
      • Resubmit the dedicated channel
      • Update dedicated channel
      • Update physical dedicated line
    • Error code
    • General Description
    • Interface Overview
    • Overview
    • Service domain
  • FAQs
    • General Problems
  • Function Release Records
  • Getting Started Guide
    • Getting Started Guide
    • On-Premises IDC and Cloud VPC Interconnection
      • Add dedicated channel
      • Add network instance
      • Apply for physical dedicated line
      • Configure user-side routing and test connectivity
      • Create dedicated gateway
  • Operation guide
    • Dedicated channel
      • Add cross-account dedicated channel
      • Add dedicated channel
      • Dedicated Channel Cross-Account Authorization for Cloud Smart Network
      • Dedicated Channel IPv6 Feature Configuration
      • Delete dedicated channel
      • Dynamic routing BGP configuration for dedicated channels
      • Static route configuration for dedicated channels
    • Dedicated gateway
      • Create dedicated gateway
      • Dedicated Gateway
    • Identity and access management
    • Monitor and Operations
      • Alarm Strategy Description
      • Dedicated Channel Instance Diagnosis
      • Fault Drill
    • Physical dedicated line
      • Apply for physical dedicated line
      • Express Tunnel process
      • Manage Physical Dedicated Line
      • Operation preparation
  • Product billing
    • Billing Item Description
    • Charge
    • Expiration description
    • Overdue description
  • Product Description
    • Application scenarios
    • Dedicated Line Access Point Address
    • Product advantages
    • Usage restrictions
    • What Is Dedicated Line Access
  • SDK
    • GO SDK
      • Dedicated line
      • Exception handling
      • Initialization
      • Install the SDK Package
      • Overview
      • Version history
    • Java-SDK
      • Dedicated line
      • Exception handling
      • Initialization
      • Install the SDK Package
      • Overview
      • Version history
    • Python SDK
      • Dedicated line
      • Function Release Records
      • Initialization
      • Install the SDK Package
      • Overview
  • Service Level Agreement (SLA)
    • Service Level Agreement (SLA)
  • Typical Practices
    • Connecting On-Premises IDC to Cloud VPC via Multi-Line ECMP (Dynamic Routing)
    • Connecting On-Premises IDC to Cloud VPC via Multi-Line ECMP (Static Routing)
    • Connecting On-Premises IDC to Cloud VPC via Primary and Backup Dedicated Lines (Dynamic Routing)
    • Connecting On-Premises IDC to Cloud VPC via Primary and Backup Dedicated Lines (Static Routing)
    • Interconnecting IDCs and VPCs Across Different Regions via Dedicated Lines
All documents
menu
No results found, please re-enter

ET

  • API Reference
    • API function release records
    • Appendix
    • Common Request Headers and Response Headers
    • Dedicated Line Related Interfaces
      • Add dedicated channel routing parameters
      • Add dedicated channel user object
      • Apply for physical dedicated line
      • Associate dedicated channel
      • Create dedicated channel
      • Create routing rules of Dedicated channel
      • Delete dedicated channel
      • Delete routing rules of dedicated channel
      • Disable dedicated channel IPv6 function
      • Disassociate dedicated channel
      • Enable IPv6 function for the dedicated channel
      • Modify the dedicated channel routing rules
      • Query dedicated channel
      • Query dedicated line details
      • Query dedicated line list
      • Query the routing rules of the dedicated channel
      • Remove dedicated channel route parameters
      • Remove dedicated channel user object
      • Resubmit the dedicated channel
      • Update dedicated channel
      • Update physical dedicated line
    • Error code
    • General Description
    • Interface Overview
    • Overview
    • Service domain
  • FAQs
    • General Problems
  • Function Release Records
  • Getting Started Guide
    • Getting Started Guide
    • On-Premises IDC and Cloud VPC Interconnection
      • Add dedicated channel
      • Add network instance
      • Apply for physical dedicated line
      • Configure user-side routing and test connectivity
      • Create dedicated gateway
  • Operation guide
    • Dedicated channel
      • Add cross-account dedicated channel
      • Add dedicated channel
      • Dedicated Channel Cross-Account Authorization for Cloud Smart Network
      • Dedicated Channel IPv6 Feature Configuration
      • Delete dedicated channel
      • Dynamic routing BGP configuration for dedicated channels
      • Static route configuration for dedicated channels
    • Dedicated gateway
      • Create dedicated gateway
      • Dedicated Gateway
    • Identity and access management
    • Monitor and Operations
      • Alarm Strategy Description
      • Dedicated Channel Instance Diagnosis
      • Fault Drill
    • Physical dedicated line
      • Apply for physical dedicated line
      • Express Tunnel process
      • Manage Physical Dedicated Line
      • Operation preparation
  • Product billing
    • Billing Item Description
    • Charge
    • Expiration description
    • Overdue description
  • Product Description
    • Application scenarios
    • Dedicated Line Access Point Address
    • Product advantages
    • Usage restrictions
    • What Is Dedicated Line Access
  • SDK
    • GO SDK
      • Dedicated line
      • Exception handling
      • Initialization
      • Install the SDK Package
      • Overview
      • Version history
    • Java-SDK
      • Dedicated line
      • Exception handling
      • Initialization
      • Install the SDK Package
      • Overview
      • Version history
    • Python SDK
      • Dedicated line
      • Function Release Records
      • Initialization
      • Install the SDK Package
      • Overview
  • Service Level Agreement (SLA)
    • Service Level Agreement (SLA)
  • Typical Practices
    • Connecting On-Premises IDC to Cloud VPC via Multi-Line ECMP (Dynamic Routing)
    • Connecting On-Premises IDC to Cloud VPC via Multi-Line ECMP (Static Routing)
    • Connecting On-Premises IDC to Cloud VPC via Primary and Backup Dedicated Lines (Dynamic Routing)
    • Connecting On-Premises IDC to Cloud VPC via Primary and Backup Dedicated Lines (Static Routing)
    • Interconnecting IDCs and VPCs Across Different Regions via Dedicated Lines
  • Document center
  • arrow
  • ET
  • arrow
  • SDK
  • arrow
  • Java-SDK
  • arrow
  • Initialization
Table of contents on this page
  • Confirm Endpoint
  • Retrieve AK/SK
  • Create EtClient
  • Create EtClient with AK/SK
  • Create EtClient with STS
  • Request STS Token
  • Create EtClientwith STS Token
  • Configure HTTPS access to ET
  • Configure EtClient
  • Use a proxy
  • Set network parameters

Initialization

Updated at:2025-11-11

Confirm Endpoint

Before configuring the endpoint for SDK usage, please refer to the developer guide section on API Service Domain Name to understand Endpoint-related concepts.

Access region Endpoint
Global bcc.bj.baidubce.com

Retrieve AK/SK

To access Baidu AI Cloud ET services, you need a valid AK (Access Key ID) and SK (Secret Access Key) for signature authentication. The AK/SK are system-generated credentials used to identify users and perform certified authentication for accessing services. You can obtain and familiarize yourself with your credentials by following these steps:

  1. Register a Baidu AI Cloud account
  2. Create AK/SK

Create EtClient

The EtClient serves as the client interface for ET services, offering developers a variety of methods to interact with ET services.

Create EtClient with AK/SK

Users can refer to the following code to create a client to access BOS with AK/SK:

Java
1public class Sample {
2    public static void main(String[] args) {
3 String ACCESS_KEY_ID =<your-access-key-id>;                   // User’s Access Key ID
4 String SECRET_ACCESS_KEY =<your-secret-access-key>;           // User’s Secret Access Key
5        
6 // Initialize an EtClient
7        EtClientConfiguration config = new EtClientConfiguration();
8        config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY));
9        EtClient client = new EtClient(config);
10    }
11}

In the code above, ACCESS_KEY_ID corresponds to “Access Key ID” in the console. SECRET_ACCESS_KEY corresponds to “Access Key Secret” in the console. For the method to retrieve them, refer to the Guide - Manage ACCESSKEY.

By default, the above method uses the ET service's default domain name as the service address. To use a custom domain, you can provide an ENDPOINT parameter.

Java
1String ACCESS_KEY_ID =<your-access-key-id>;                   // User’s Access Key ID
2 String SECRET_ACCESS_KEY =<your-secret-access-key>;           // User’s Secret Access Key
3 String ENDPOINT = <domain-name>;                               // User-defined domain name
4 EtClientConfiguration config = new EtClientConfiguration();
5 config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID,SECRET_ACCESS_KEY));
6 config.setEndpoint(ENDPOINT);
7 EtClient client = new EtClient(config);

Create EtClient with STS

Request STS Token

ET supports temporary third-party access authorization via the STS mechanism. STS (Security Token Service) is a temporary authorization service provided by Baidu AI Cloud. It enables you to generate short-term credentials with tailored permissions and validity periods for third-party users, allowing them to directly access cloud resources via Baidu AI Cloud APIs or SDKs.

To access ET via STS, users must first request a certification string through the STS client. For instructions on obtaining STS credentials, refer to Baidu AI Cloud STS Usage Guide。

Create EtClientwith STS Token

After requesting the STS token, configure it in the EtClient. The following codes demonstrate how to create an EtClient:

Java
1public class StsExample {
2    private static final String STS_ENDPOINT = "http://sts.bj.baidubce.com";
3    private static final String ACCESS_KEY_ID = "your accesskey id";
4    private static final String SECRET_ACCESS_KEY = "your secret accesskey";
5    public static void main(String[] args) {
6        BceCredentials credentials = new DefaultBceCredentials(ACCESS_KEY_ID, SECRET_ACCESS_KEY);
7        StsClient client = new StsClient(
8                new BceClientConfiguration().withEndpoint(STS_ENDPOINT).withCredentials(credentials)
9        );
10        GetSessionTokenResponse response = client.getSessionToken(new GetSessionTokenRequest());
11        // or simply call:
12        // GetSessionTokenResponse response = client.getSessionToken();
13        // or you can specify limited permissions with ACL:
14        // GetSessionTokenResponse response = client.getSessionToken(new GetSessionTokenRequest().withAcl("blabla"));
15        // build DefaultBceSessionCredentials object from response:
16        BceCredentials etStsCredentials = new DefaultBceSessionCredentials(
17                response.getAccessKeyId(),
18                response.getSecretAccessKey(),
19                response.getSessionToken());
20        System.out.println("==================================");
21        System.out.println("GetSessionToken result:");
22        System.out.println("    accessKeyId:  " + response.getAccessKeyId());
23        System.out.println("    secretAccessKey:  " + response.getSecretAccessKey());
24        System.out.println("    securityToken:  " + response.getSessionToken());
25        System.out.println("    expiresAt:  " + response.getExpiration().toString());
26        System.out.println("==================================");
27        // build ET client
28        EtClientConfiguration config = new EtClientConfiguration();
29        config.setCredentials(etStsCredentials);
30        EtClient client = new EtClient(config);
31    }
32}

Note: Currently, when configuring a client with STS, regardless of where the corresponding ET service endpoint is located, the endpoint must be set to http://sts.bj.baidubce.com.

Configure HTTPS access to ET

ET supports HTTPS transport protocol. You can use HTTPS to access the ET service in the ET Java SDK in the following two ways:

  • Specify HTTPS in the endpoint:
Java
1 String endpoint = "https://bcc.bj.baidubce.com";
2 String ak = "ak";
3 String sk = "sk";
4 EtClientConfiguration config = new EtClientConfiguration();
5 config.setCredentials(new DefaultBceCredentials(ak, sk));
6 EtClient client = new EtClient(config);
  • Configure HTTPS by calling setProtocol:
Java
1String endpoint = "bcc.bj.baidubce.com"; // endpoint without protocol
2 String ak = "ak";
3 String sk = "sk";
4 EtClientConfiguration config = new EtClientConfiguration();
5 config.setCredentials(new DefaultBceCredentials(ak, sk));
6 config.setEndpoint(ENDPOINT);
7 config.setProtocol(Protocol.HTTPS); // Defaults to HTTP if unspecified
8 EtClient client = new EtClient(config);

Note: If the endpoint already includes a protocol, the one in endpoint takes effect, and the setProtocol() method will be ignored.

Java
1 String endpoint = "http://bcc.bj.baidubce.com";
2 String ak = "ak";
3 String sk = "sk";
4 EtClientConfiguration config = new EtClientConfiguration();
5 config.setCredentials(new DefaultBceCredentials(ak, sk));
6 config.setEndpoint(ENDPOINT);    
7 config.setProtocol(Protocol.HTTPS); // Invalid operation if specified in endpoint, applicable to HTTP cases
8 EtClient client = new EtClient(config);

Configure EtClient

To configure customization options for the EtClient, initialize it with an EtClientConfiguration object. This allows you to specify proxy settings, maximum connections, or other network-related configurations.

Use a proxy

The following code snippet enables the client to access ET service using a proxy:

Java
1String ACCESS_KEY_ID =<your-access-key-id>;                   // User’s Access Key ID
2 String SECRET_ACCESS_KEY =<your-secret-access-key>;           // User’s Secret Access Key
3 String ENDPOINT = <domain-name>;                               // User-defined domain name
4 // Create EtClientConfiguration instance
5 EtClientConfiguration config = new EtClientConfiguration();
6 // Configure proxy to local port 8080
7 config.setProxyHost("127.0.0.1");
8 config.setProxyPort(8080);
9 // Create ET client
10 config.setCredentials(new DefaultBceCredentials(ACCESS_KEY_ID,SECRET_ACCESS_KEY));
11 config.setEndpoint(ENDPOINT);
12 EtClient client = new EtClient(config);

All client requests will then be routed through the proxy at 127.0.0.1:8080.

For verified proxies, configure credentials:

Plain Text
1// Create EtClientConfiguration instance
2 EtClientConfiguration config = new EtClientConfiguration();
3    
4 // Configure proxy to local port 8080
5 config.setProxyHost("127.0.0.1");
6 config.setProxyPort(8080);
7    
8 // Set username and password
9 config.setProxyUsername(<username>);                             // Username
10 config.setProxyPassword(<password>);                             // Password

Set network parameters

Users may set the basic network parameters with EtClientConfiguration:

Java
1EtClientConfiguration config = new EtClientConfiguration();
2    
3 // Set maximum number of HTTP connections to 10
4config.setMaxConnections(10);
5    
6 // Set TCP connection timeout to 5,000 milliseconds
7config.setConnectionTimeout(5000);
8    
9 // Set timeout for Socket data transmission to 2,000 milliseconds
10config.setSocketTimeout(2000);

Parameter description The following parameters can be configured via EtClientConfiguration:

Parameters Description
UserAgent User agent, refers to HTTP’s User-Agent header
Protocol Connection protocol type
ProxyDomain Windows domain for NTLM-verified proxy
ProxyHost Proxy server host address
ProxyPort Proxy server port
ProxyUsername Proxy verification username
ProxyPassword Proxy verification password
ProxyPreemptiveAuthenticationEnabled Enable user agent verification or not
ProxyWorkstation NTLM proxy workstation name
LocalAddress Local address
ConnectionTimeoutInMillis Timeout for establishing TCP connections (unit: ms)
SocketTimeoutInMillis Timeout for socket data transmission (unit: ms)
MaxConnections Maximum allowable HTTP connections
RetryPolicy Retry policy for connections
SocketBufferSizeInBytes Buffer size for socket operations

Previous
Exception handling
Next
Install the SDK Package