'Bitbucket how to replace Basic auth while uploading a file via api?

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.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source