public void handleRequest()

in solution/solution-fc-sts-token/code-example/java/src/main/java/org/example/aliyun_sdk/App.java [18:32]


    public void handleRequest(InputStream inputStream, OutputStream outputStream, Context context) {
        // 从上下文获取凭证信息
        Credentials creds = context.getExecutionCredentials();

        try {
            Config config = new Config().setRegionId("cn-hangzhou").setCredential(createCredential(creds));

            // 查看当前调用者身份
            Client stsClient = new Client(config);
            GetCallerIdentityResponse getCallerIdentityResponse = stsClient.getCallerIdentity();
            outputStream.write(JSON.toJSONString(getCallerIdentityResponse).getBytes());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }