Preparations (SDK for Java)
Before using OBS SDK for Java to access OBS, you need to prepare the service and development environments. To prepare the service environment, you will need an account and access keys. Both of them are necessary for interaction between OBS SDK and OBS. To ensure successful SDK installation and SDK-based code development and running, you should also set up a local development environment, for example, installing dependencies and development tools.
Preparing a HUAWEI ID
To use OBS, you must have a HUAWEI ID. For details, see Creating a HUAWEI ID and Enabling Huawei Cloud Services.
Preparing Access Keys
Access keys consist of two parts: an access key ID (AK) and a secret access key (SK). OBS uses access keys to sign requests to make sure that only authorized accounts can access specified OBS resources. Programmatic access must be enabled for an IAM user before the IAM user can get access keys. To enable programmatic access, see Viewing or Modifying IAM User Information. Access keys are explained as follows:
- One AK maps to only one user but one user can have multiple AKs. OBS authenticates users by their AKs.
- An SK is required for accessing OBS. Authentication information is generated based on the SK and request headers. AKs and SKs are in one-to-one match.
Access keys are permanent. There are also temporary security credentials (consisting of an AK/SK pair and a security token). Each user can create a maximum of two valid AK/SK pairs. Temporary security credentials can only be used to access OBS within the specified validity period. Once they expire, they must be requested again. For security purposes, you are advised to use temporary security credentials to access OBS. If you want to use permanent access keys, periodically update them. The following describes how to obtain access keys of these two types.
- To get permanent access keys, do as follows:
- Log in to OBS Console.
- In the upper right corner, hover over the username and choose My Credentials.
- On the My Credentials page, click Access Keys in the navigation pane.
- On the Access Keys page, click Create Access Key.
- In the displayed dialog box, enter the login password and verification code.
- If you have not bound an email address or a mobile number yet, only the login password is required.
- If you have bound both an email address and a mobile number, you can use either of them for verification.
- Click OK.
- Click Download. The access key file is automatically saved to your browser's default download path.
- Open the downloaded credentials.csv file to obtain the AK and SK.
- Each user can create a maximum of two valid access key pairs.
- Keep AKs and SKs properly to prevent information leakage. If you click Cancel in the download dialog box, the access keys will not be downloaded and cannot be downloaded later. You can create a new AK/SK pair if needed.
- To get temporary security credentials, refer to the following:
Temporary security credentials are issued by the system and are only valid for 15 minutes to 24 hours. They follow the principle of least privilege. When using temporary security credentials, you must use an AK/SK pair and a security token together.
To obtain them, see Obtaining a Temporary AK/SK and a Security Token.
OBS is a global service. When obtaining temporary access keys, set the token scope to domain to apply the token to global services. Global services are not differentiated by any project or region.
Setting Up a Development Environment
- Download a recommended JDK version from the Oracle's official website and install it. Recommended JDK versions: JDK 8 or later
- The latest version of Eclipse IDE for Java Developers is required and can be downloaded from the Eclipse's official website.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.