Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Authenticate by Passing Parameters

Warning

Do NOT expose clear text password in the URL or DOM.

For JSON API authentication purposes, the following parameters can be posted /appended to each of the JSON API URLs:

  • j_username
  • j_password
  • hash

Example:

Assuming the username and password required is "user1" and "password1" respectively, we can post the username and password to the JSON API using following jQuery script.

Code Block
languagejsbash
titleSample Call
curl --location --request POST --data 'j_username=user1&j_password=password1' <script>
    $(document).ready(function(){
        $.ajax({
            type: "POST",
            url: 'http://localhost:8080/jw/web/json/workflow/assignment/list'
Code Block
languagebash
titleSample Result
{"total" : 12 }/pending',
            data: {
				j_username : 'user1',
 				j_password : 'password1'
			},
            success: function(res) {
                console.log(res)
            },
            dataType: "json"
        });
    });
</script>

If you prefer to use hashed password, you can use the following script.

Note

Please note that the support on Hashed Password is based on the Directory Manager you are using. Some Directory Manager Plugin may not supporting this type of authentication method.

The format and hashing method may vary for each Directory Manager as well.

Code Block
languagejsbash
titleSample Call
curl --location --request POST --data 'j_username=user1&hash=D012B772672A55A0B561EAA53CA7734E' <script>
    $(document).ready(function(){
        $.ajax({
            type: "POST",
            url: 'http://localhost:8080/jw/web/json/workflow/assignment/list/pending',
            data: {
				j_username : 'user1',
 				hash : 'D012B772672A55A0B561EAA53CA7734E'
			},
            success: function(res) {
                console.log(res)
            },
            dataType: "json"
        });

    });
</script>

 

Master Login Username and Password

Warning

Do NOT expose clear text password in the URL or DOM.

When authentication using parameters, you are allowed to using a Master Credential to login as other user to performance workflow activities. 

...

The following example showcases how to use a Master Credential to login as "user1".

Code Block
languagejsbash
titleSample Call
curl --location --request POST --data 'j_username=master&j_password=master&loginAs=user1' <script>
    $(document).ready(function(){
        $.ajax({
            type: "POST",
            url: 'http://localhost:8080/jw/web/json/workflow/assignment/list/pending',
            data: {
				j_username : 'master',
 				j_password : 'master',
 				loginAs : 'user1'
			},
            success: function(res) {
                console.log(res)
            },
            dataType: "json"
        });
    });
</script>

Using master login hash:

'

Using master login hash:

Code Block
languagebash
titleSample Call
curl --location --request POST --data 'j_username=master&j_password=master&loginAs=user1' 
Code Block
languagejs
<script>
    $(document).ready(function(){
        $.ajax({
            type: "POST",
            url: 'http://localhost:8080/jw/web/json/workflow/assignment/list/pending',
            data: {
				j_username : 'master',
 				hash : 'E505CF727D214A68CB03DA25DA978500',
 				loginAs : 'user1'
			},
            success: function(res) {
                console.log(res)
            },
            dataType: "json"
        });
    });
</script>

Basic Http Authentication

Since V4, Joget Workflow is suppoeted supports Basic HTTP Authentication in JSON API authentication , so you can passing pass the credentials in the header.

Example:
Assuming the username and password required is "user1" and "password1" respectively, we can set the Basic Auth header to the JSON API using following jQuery script.

 

Code Block
languagejsbash
titleSample Call
curl --location --request POST <script>
    $(document).ready(function(){
        $.ajax({
            type: "POST",
            url: 'http://localhost:8080/jw/web/json/workflow/assignment/list/pending',
            beforeSend: function (xhr) {
    			xhr.setRequestHeader ("Authorization", "Basic dXNlcjE6cGFzc3dvcmQx");
			},
            success: function(res) {
                console.log(res)
            },
            dataType: "json"
        });
    });
</script>--header 'Authorization: Basic dXNlcjE6cGFzc3dvcmQx'