Hi,
Could you please help me for some javascript code sample for authentication with REST API?
I am using JIRA - v7.1.10
Hi @Prasad ,
I use groovy:
class HttpProvider(){private static String authStringprivate static credentional(){Console conscons = System.console()username = cons.read("[%s]", 'Username:')password = cons.readPassword("[%s]", 'Password:')this.authString = "${username}:${password}".getBytes().encodeBase64().toString()}private static get(String url) {def connection = url.toURL().openConnection()if (this.authString == null) this.credentional()connection.addRequestProperty("Authorization", "Basic ${this.authString}")connection.setRequestMethod("GET")connection.doOutput = falseconnection.connect()connection.content.text}}
In groovy by default return last operator in method. In java it equals: return connection.content.text
B.R.
Hi @Prasad
Just to add a bit to @Andrew answer, the username needs to be the Jira e-mail address and the password needs to be the API token, as per this post
Hi @Andrew and @Warren .
Thank you for answer. I want to know whether we cannot use plane JavaScript for authentication?
It looks like you're new here. Sign in or register to get started.