Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New-JiraSession not working with PAT - UPDATE DOCUMENTATION #448

Open
childsc opened this issue Jan 18, 2022 · 3 comments
Open

New-JiraSession not working with PAT - UPDATE DOCUMENTATION #448

childsc opened this issue Jan 18, 2022 · 3 comments

Comments

@childsc
Copy link

childsc commented Jan 18, 2022

Description

We will be looking to disable the basic Authentication against Jira in the next few months. However we are not able to create new sessions when using the PAT.
According to the documentation we are supposed to use the user's email address and the PAT to create a session. However, this does not appear to be working.
https://atlassianps.org/docs/JiraPS/about/authentication.html#api-token

Steps To Reproduce

  1. Go to profile and create a new PAT
  2. Perform the following script:
  3. $password = ConvertTo-SecureString '<TOKEN>' -AsPlainText -Force $creds = New-Object System.Management.Automation.PSCredential ('[email protected]', $password) New-JiraSession -Credential $creds

Expected behavior

Expected to see the following (as we see with basic Auth):

Username WebSession


test Microsoft.PowerShell.Commands.WebRequestSession

Your Environment

Get-Module JiraPS -ListAvailable | Select Name, Version

Name   Version
----   -------
JiraPS 2.14.6

$PSVersionTable
Name                           Value
----                           -----
PSVersion                      7.2.1
PSEdition                      Core
GitCommitId                    7.2.1
OS                             Microsoft Windows 10.0.19044
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
@Alreanaes
Copy link

Alreanaes commented Mar 4, 2022

tldr; try New-JiraSession -Headers @{Authorization="Bearer <PAT Token>"} -Credential $([System.Management.Automation.PSCredential]::Empty)

I was having a similar issue authenticating to a Jira Server instance. All the documentation is for Jira Cloud.
I was able to find an explanation of the difference when using a PAT here and I confirmed with curl.
So, I took a dive into New-JiraSession and then Invoke-JiraMethod.
Apparently you can use empty credentials
$creds = [System.Management.Automation.PSCredential]::Empty
and manually create the authorization header.
New-JiraSession -Headers @{Authorization="Bearer <PAT Token>"} -Credential $creds

@childsc
Copy link
Author

childsc commented Mar 31, 2022

This should actually by Please update the Documentation around PAT. Many thanks @Alreanaes

@childsc childsc changed the title New-JiraSession not working with PAT New-JiraSession not working with PAT - UPDATE DOCUMENTATION Apr 1, 2022
@ybeltrikov
Copy link

Using JiraPS 2.14.6 trying to connect to Jira Server and on
New-JiraSession -Headers @{Authorization="Bearer <PAT Token>"} -Credential $([System.Management.Automation.PSCredential]::Empty

I get an error:
Invoke-JiraMethod : token contains an invalid number of segments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants