Initialization

IAM IAM

  • API Reference
    • Common request header and common response header
    • Data type
    • Error code
    • Feature Update Records
    • General Description
    • Introduction
    • Service domain
    • STS-Related Interfaces
  • API Reference_IAM
    • Common request header and common response header
    • Data type
    • Error code
    • General Description
    • Group management API
    • Introduction
    • Policy management API
    • Role Management Interfaces
    • Service domain
    • User management API
  • FAQs
    • Common Questions Overview
    • FAQs related to IAM users
    • FAQs related to product permissions
  • Function Release Records
  • Operation guide
    • Account Security Audit
    • Enterprise Account Integration
      • Federated Login Overview
      • IAM Role-based SSO
      • IAM User-based SSO
    • Group Management
    • Message Center
    • Permission Policies
      • ACL
      • Authorization
      • Managing IAM Policies
      • Permission Policy Overview
      • Policy Authentication Evaluation Logic
      • Strategy type
      • Tag-Based Authorization and Authentication
    • Role Management
      • Common scenarios
      • Create role
      • FAQs
      • Managing Roles
      • Overview
      • Related concepts
      • Using Roles
    • Settings
    • User
      • IAM User Operations
      • Two-Factor Authentication
      • User management
    • User Anomaly Behavior Analysis (Public Beta)
      • Risk Behavior Management
  • Operation records
    • Cloud Trail (Public Beta)
  • Product Announcement
    • Baidu Intelligent Cloud Enables Login Protection MFA Multi-Factor Authentication Notification for All Users
  • Product Description
    • Application scenarios
    • Concepts
    • Currently Supported Product Lines
    • Product functions
    • Product overview
    • System Restrictions
    • Enterprise Organization vs Identity and Access Management
  • Product pricing
    • Product pricing
  • Quick Start
    • Create groups and grant permissions
    • Creating IAM User Administrators
  • SDK
    • Go-SDK
      • Error handling
      • Group management API
      • Initialize SDK
      • Install the SDK Package
      • Overview
      • Policy management API
      • Role Management Interfaces
      • User management API
      • Version Change Records
    • Java-SDK
      • Error code
      • Group management API
      • Initialization
      • Install the SDK Package
      • Overview
      • Policy management API
      • Role Management Interfaces
      • User management API
      • Version Change Records
    • Python-SDK
      • Error code
      • Group management API
      • Initialization
      • Install the SDK Package
      • Overview
      • Policy management API
      • Role Management Interfaces
      • User management API
      • Version Change Records
  • Testing Knowledge Base SDK
  • Typical Practices
    • Baidu Intelligent Cloud Partner Guide to Creating IAM Users
    • User Management and Permission Assignment
All documents
menu
No results found, please re-enter

IAM IAM

  • API Reference
    • Common request header and common response header
    • Data type
    • Error code
    • Feature Update Records
    • General Description
    • Introduction
    • Service domain
    • STS-Related Interfaces
  • API Reference_IAM
    • Common request header and common response header
    • Data type
    • Error code
    • General Description
    • Group management API
    • Introduction
    • Policy management API
    • Role Management Interfaces
    • Service domain
    • User management API
  • FAQs
    • Common Questions Overview
    • FAQs related to IAM users
    • FAQs related to product permissions
  • Function Release Records
  • Operation guide
    • Account Security Audit
    • Enterprise Account Integration
      • Federated Login Overview
      • IAM Role-based SSO
      • IAM User-based SSO
    • Group Management
    • Message Center
    • Permission Policies
      • ACL
      • Authorization
      • Managing IAM Policies
      • Permission Policy Overview
      • Policy Authentication Evaluation Logic
      • Strategy type
      • Tag-Based Authorization and Authentication
    • Role Management
      • Common scenarios
      • Create role
      • FAQs
      • Managing Roles
      • Overview
      • Related concepts
      • Using Roles
    • Settings
    • User
      • IAM User Operations
      • Two-Factor Authentication
      • User management
    • User Anomaly Behavior Analysis (Public Beta)
      • Risk Behavior Management
  • Operation records
    • Cloud Trail (Public Beta)
  • Product Announcement
    • Baidu Intelligent Cloud Enables Login Protection MFA Multi-Factor Authentication Notification for All Users
  • Product Description
    • Application scenarios
    • Concepts
    • Currently Supported Product Lines
    • Product functions
    • Product overview
    • System Restrictions
    • Enterprise Organization vs Identity and Access Management
  • Product pricing
    • Product pricing
  • Quick Start
    • Create groups and grant permissions
    • Creating IAM User Administrators
  • SDK
    • Go-SDK
      • Error handling
      • Group management API
      • Initialize SDK
      • Install the SDK Package
      • Overview
      • Policy management API
      • Role Management Interfaces
      • User management API
      • Version Change Records
    • Java-SDK
      • Error code
      • Group management API
      • Initialization
      • Install the SDK Package
      • Overview
      • Policy management API
      • Role Management Interfaces
      • User management API
      • Version Change Records
    • Python-SDK
      • Error code
      • Group management API
      • Initialization
      • Install the SDK Package
      • Overview
      • Policy management API
      • Role Management Interfaces
      • User management API
      • Version Change Records
  • Testing Knowledge Base SDK
  • Typical Practices
    • Baidu Intelligent Cloud Partner Guide to Creating IAM Users
    • User Management and Permission Assignment
  • Document center
  • arrow
  • IAMIAM
  • arrow
  • SDK
  • arrow
  • Python-SDK
  • arrow
  • Initialization
Table of contents on this page
  • Confirm Endpoint
  • Retrieve access key
  • Create IamClient
  • Configure IamClient
  • Set network parameters

Initialization

Updated at:2025-10-27

Confirm Endpoint

Baidu AI Cloud currently supports multiple regions. Please refer to[Region Selection Guide](Reference/Region Selection Instructions/Region.md).

Currently, only the "North China-Beijing" region is supported. Beijing region: https://iam.bj.baidubce.com Corresponding information:

Access region Endpoint Supported protocols
BJ iam.bj.baidubce.com HTTP,HTTPS

Retrieve access key

To use Baidu AI Cloud IAM, you need valid AK (Access Key ID) and SK (Secret Access Key) credentials for signature authentication. AK/SK are system-assigned strings used for user identification and signature verification in IAM. You can obtain and understand your AK/SK details using the following steps:

Register a Baidu AI Cloud account

Create AK/SK

Create IamClient

The IamClient acts as the client for IAM services, offering developers a range of methods to interact with IAM services.

  1. Before creating IamClient, a configuration file must be created to configure IamClient. Below, this configuration file is named iam_sample_conf.py, with the following specific configuration information:
Python
1#Import standard logging module
2import logging
3 #Introduce configuration management module and security certification module
4from baidubce.bce_client_configuration import BceClientConfiguration
5from baidubce.auth.bce_credentials import BceCredentials
6 #Set the Host, Access Key ID and Secret Access Key
7HOST = ''
8AK = ''
9SK = ''
10 #Set log file handles and log levels
11logger = logging.getLogger('baidubce.services.iam.iamclient')
12fh = logging.FileHandler('sample.log')
13fh.setLevel(logging.DEBUG)
14 #Set the order, structure and content of log file output
15formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
16fh.setFormatter(formatter)
17logger.setLevel(logging.DEBUG)
18logger.addHandler(fh)
19 #Create BceClientConfiguration instance
20config = BceClientConfiguration(credentials=BceCredentials(AK, SK), endpoint=HOST)
  1. Create IamClient, refer to sample/iam/iam_sample.py
Python
1#Import configuration module
2import iam_sample_conf
3 #Import IamClient module
4from baidubce.services.iam.iam_client import IamClient
5 #Create IamClient
6iam_client = IamClient(iam_sample_conf.config)

Configure IamClient

Set network parameters

Users can set some network parameters:

Python
1    #Set request timeout duration
2iam_sample_conf.config.connection_timeout_in_mills = TIMEOUT
3    	
4 #Set receive buffer size
5iam_sample_conf.config.recv_buf_size(BUF_SIZE)
6
7 #Set send buffer size
8iam_sample_conf.config.send_buf_size(BUF_SIZE)
9
10 #Set connection retry policy
11 #Three-time exponential backoff retry
12iam_sample_conf.config.retry_policy = BackOffRetryPolicy()

Parameter description

The following parameters can be configured via BceClientConfiguration:

Parameters Description
send_buf_size Send buffer size
recv_buf_size Receive buffer size
connection_timeout_in_mills Request timeout duration (unit: millisecond)
retry_policy For the connection retry policy, default to three-time exponential backoff during Client initialization

Previous
Group management API
Next
Install the SDK Package