Hi,
Currently I am developing a macro for a special user search. On the frontend you have the macro that runs in its current state as planed. The problem arises with the backend. The search is handled via an api which is in development.
On one hand you are able to get the current useres credentials inside the macro, so could the api check the authentication against the confluence instance?
Or is there a better way?
Thanks!
Please feel free to ask if I didn't make something clear.
You can add an authentication header. Here's a basic REST request macro script that includes the header.
Keep in mind that you may run into an error with CORS:
## Basic REST call with authentication in a Confluence Macro
## @noparams
<script type="text/javascript">
AJS.toInit(function() {
jQuery.ajax({
url: "<url>",
type: "GET",
contentType: "application/json",
beforeSend: function(xhr) {
xhr.setRequestHeader("Authorization", "Basic " + btoa("username:password"));
},
success: function(data) {
console.log("HTTP request was successful.");
console.log(data);
},
error: function(xhr, status, error) {
console.log("HTTP request failed. Error message: " + error);
}
});
});
</script>
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.