With reference to the document below, I am trying to create a secret at a repository level for GitHub actions.
https://docs.github.com/en/rest/reference/actions (Create or update a repository secret)
So far I have written the following code and I am getting 500 error. Not sure what I am missing
SodiumJava sodiumJava = new SodiumJava();
LazySodiumJava lazySodium = new LazySodiumJava(sodiumJava);
Key key = lazySodium.keygen(AEAD.Method.CHACHA20_POLY1305);
byte[] nPub = lazySodium.nonce(AEAD.CHACHA20POLY1305_NPUBBYTES);
//Step 1 is password.
String password = "password";
//Step 2 is to encrypt value
String encrypted_value = lazySodium.encrypt(
password,
null,
nPub,
key,
AEAD.Method.CHACHA20_POLY1305);
//Step 3 is to get the encoded value.
String encodedValue = new String(Base64.encodeBase64(encrypted_value.getBytes()));
Map<String, String> map = new HashMap<>();
map.put("encrypted_value", encodedValue);
map.put("key_id", "1");
map.put("visibility", "all");
final HttpEntity<?> bodyThis = new HttpEntity<>(map, headers);
String urlTest = "https://someurl***/repos/owner/repo_name/actions/secrets/secret_name";
ResponseEntity<Object> demo = restTemplate.exchange(urlTest, HttpMethod.PUT, bodyThis, new ParameterizedTypeReference<Object>() {
});