How do I log on to JIRA in PowerShell using REST when basic authentication in plain text is blocked?

Viewed 25

I've been trying to access our on-prem JIRA Server (configured with plain HTTP) using PowerShell Invoke-RestMethod, but I think I'm missing something.

The authentication header is created in base64

$cred = [convert]:.ToBase64String([text.encoding]::ASCII.GetBytes("account:password"))
$headers = @{Authorization = "Basic $cred"}

Using REST, I then ask for the issue (without posting any property filter to keep the request simple while I'm learning).

Invoke-RestMethod -Uri http://jiraserver:8080/jira-software/REST/agile/1.0/issue/test-1 `
   -Headers $headers -ContentType "application/json" -AllowUnencryptedAuthentication

This obviously fails, as I get back a reply containing a login form

<form action="/login.jsp"
    class="aui"

    id="login-form"

    method="post">

I do think I remember that basic authentication is no longer supported in JIRA.

How do I use OAuth in that case instead?

1 Answers

When working with another task that is well within the scope of Atlassian“s PowerShell module JiraPS, I noticed a command called Invoke-JiraMethod.

It turns out that the module provides JIRA REST API access :)

So by setting up a JIRA session with the PowerShell module, I'll be able to use REST over an unencrypted connection.

Related