Bitbucket如何在通过api上传文件时替换基本身份验证?

发布于 2025-01-09 08:14:36 字数 846 浏览 2 评论 0原文

主要尝试使用基本身份验证进行身份验证。到 2021 年 10 月为止,它在生产中运行得很好。后来它被标记为已弃用。我尝试用 Base64 编码的用户名+应用程序密码替换基本凭据,之前是 Base64 编码的用户名+明文密码,但没有成功。

            builder.addFormDataPart("message", pushModel.getMessage());
            builder.addFormDataPart("branch", pushModel.getBranch());
            builder.addFormDataPart(pushModel.getThemeConfigPath(), updatedContent);
            RequestBody body = builder.build();

            HttpUrl.Builder urlBuilder = HttpUrl.parse(urlString).newBuilder();

            String url = urlBuilder.build().toString();

            Request request = new Request.Builder().url(url).header("Authorization", "Basic ***********").post(body).build();

            Response response = client.newCall(request).execute();

有一些选项可以使用 oauth 进行身份验证,但此 api 调用发生在后端,无需 ui 交互。所需要做的就是从该应用程序上传文件,而前置步骤是对其进行身份验证。

Primarily tried to authenticate with Basic auth. this was working very well in production till October 2021. Later this was marked as deprecated. I tried to replace the basic credentials with base64 encoded username+app password which earlier was base64 encoded username+plaintext password, yet no luck.

            builder.addFormDataPart("message", pushModel.getMessage());
            builder.addFormDataPart("branch", pushModel.getBranch());
            builder.addFormDataPart(pushModel.getThemeConfigPath(), updatedContent);
            RequestBody body = builder.build();

            HttpUrl.Builder urlBuilder = HttpUrl.parse(urlString).newBuilder();

            String url = urlBuilder.build().toString();

            Request request = new Request.Builder().url(url).header("Authorization", "Basic ***********").post(body).build();

            Response response = client.newCall(request).execute();

There are options to authenticate with oauth but this api call happens in the backend without ui interraction. All that is required is to upload a file from this application, and the prestep is to authenticate it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文