• CLI

sdk
  1. Help Center
  2. CLI
  3. Developer Guide
  4. SDK
  5. JAVA
  6. IAM Java SDK Demo

IAM Java SDK Demo

Service Authentication

IAM is a service that provides API client authentication. After you are authorized by IAM, you can call other service APIs, such as APIs used for creating ECSs.

Authentication code example:

OSClientV3 os = OSFactory.builderV3() 
.endpoint(("https://iam.example.com/v3") 
.credentials("username", "password", Identifier.byName("domain_name")) 
.scopeToProject(Identifier.byId("project_id")) 
.authenticate();
Table 1 Parameter description

Parameter

Description

username

Specifies the username.

password

Specifies a password.

domain_name

For details, see How Can I Obtain domain_name, project_name, and project_id?.

project_id

For details, see How Can I Obtain domain_name, project_name, and project_id?.

User Management

Domain-level authentication is used for user management operations.

OSClientV3 os = OSFactory.builderV3() 
.endpoint("https://iam.example.com/v3") 
.credentials("username", "password", Identifier.byName("domain_name")) 
.scopeToDomain(Identifier.byName("domain_name")) 
.authenticate();
Table 2 Parameter description

Parameter

Description

username

Specifies the username.

password

Specifies the password.

domain_name

Domain name of the user.

For details, see How Can I Obtain domain_name, project_name, and project_id?.