调用graph api时发生sun.security.validator.validatorexception

ndh0cuux  于 2021-07-24  发布在  Java
关注(0)|答案(0)|浏览(246)

我在本地使用swagger调用microsoftgraphapi时遇到以下异常。
获取以下异常:feign.retryableexception:sun.security.validator.validatorexception:pkix路径生成失败:sun.security.provider.certpath.suncertpathbuilderexception:找不到有效的证书路径

@Override
  public int addUser(String token, AddUserRequest request) {
    Response response = null;
    int status = 0;
    try {
        long time1 = System.currentTimeMillis();
        response = graphAPIFeignClient.addUser("Bearer " + token, request);
        log.info("{}:: Time taken to call Graph Api is {}", loggingComponentName, 
        (System.currentTimeMillis() - time1));

        if (response.status() == 200) {
            status = response.status();
        } else if (response.status() == 404) {
            throw new SearchResultNotFoundException("get users not found");
        } else {
            log.error("{}:: Graph Api failed:: status code {}",
                    loggingComponentName, 500);
            throw new AccessManagementException(HttpStatus.valueOf(500), "Graph Api failed");
        }

    } catch (FeignException ex) {
        log.error("{}:: Graph Api failed:: status code {} & message {}",
                loggingComponentName, ex.status(), ex.getMessage());
        throw new AccessManagementException(HttpStatus.valueOf(ex.status()), "Graph Api failed");
     }
     return status;
   }

      //feign client declaration
     @PostMapping(value = "/v1.0/users")
     @RequestLine("POST v1.0/users")
     //@Headers({"Authorization: {authorization}","Content-Type: application/json"})
     Response addUser(@RequestHeader(HttpHeaders.AUTHORIZATION) String authorisation,
                                     @RequestBody AddUserRequest request);

在 Postman 电话中也可以使用同样的方法。请在此处输入图像描述

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题