All Products
Search
Document Center

Demo code for using a temporary STS token

Last Updated: Sep 09, 2021

You can call the AssumeRole operation to obtain a temporary AccessKey pair and a Security Token Service (STS) token. You can use the temporary AccessKey pair and STS token to create an OpenSearch object.

OpenSearch openSearch = new OpenSearch("<Temporary AccessKey ID>",
    "<Temporary AccessKey secret>", "http://opensearch-cn-hangzhou.aliyuncs.com");
openSearch.setSecurityToken("<Temporary STS token>");