原创

如何在 Spring Boot 中验证 gitlab 访问令牌?

温馨提示:
本文最后更新于 2024年04月12日,已超过 48 天没有更新。若文章内的图片失效(无法正常加载),请留言反馈或直接联系我

I'm getting gitlab private token in request param. How to validate this token valid or not.

I have used gitlab4j-api maven dependency but getting error:

java.lang.ClassNotFoundException: javax.ws.rs.core.StreamingOutput

tried below code:

 @PostMapping("/validate-token")
    public void validateToken(@RequestParam String token, @RequestBody Object json) {
        System.out.printf("json " + json);
        System.out.println("Token " + token);


        //TODO need to fix error on below line.
        GitLabApi gitLabApi = new GitLabApi("https://gitlab.com", token);


        System.out.println("gitLabApi " + gitLabApi.toString());
        UserApi userApi = gitLabApi.getUserApi();
        System.out.println("UserApi " + userApi);
        if (userApi != null) {
            System.out.println("token is valid");
        } else {
            System.out.println("token is not valid");
        }

    }
正文到此结束
热门推荐
本文目录