tencentyun / qcloud-cos-sts-sdk

QCloud COS STS SDK for Backend Server
MIT License
200 stars 188 forks source link

soc-sts-java获取临时令牌失败 #42

Closed Hunter0125 closed 4 years ago

Hunter0125 commented 4 years ago

sdk使用3.0.8版本,参考官方Demo编写,日志报错如下

java.io.IOException: result = {"Response":{"Error":{"Code":"InvalidParameter.ResouceError","Message":"[QC_STS] resource error"},"RequestId":"90d7e639-4068-4735-8da3-beeef74cda27"}} 对比官网错误码描述,说是策略resource字段不合法。 然后我反复对照了官网针对resource的要求,完全符合规定啊,为何还是报错

Hunter0125 commented 4 years ago

找到原因了,如果项目有使用spring-boot-starter-test,需要排除一个内置依赖,不然JSONObject操作会异常,配置如下:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
    <exclusions>
        <exclusion>
            <groupId>com.vaadin.external.google</groupId>
            <artifactId>android-json</artifactId>
        </exclusion>
    </exclusions>
</dependency>