AtlassianPS / JiraPS

PowerShell module to interact with Atlassian JIRA
https://AtlassianPS.org/module/JiraPS
MIT License
322 stars 131 forks source link

Unable to authenticate with New_Jirasession #389

Closed rschmidt2 closed 4 years ago

rschmidt2 commented 4 years ago

I am using these commands to test Jiraps:

Install-Module JiraPS -Scope CurrentUser
Update-Module JiraPS
Import-Module JiraPS
set-jiraconfigserver -server "Https://<my Jira Service Desk site>"
 $cred = get-credential

All seems fine until the next step

 New-JiraSession -Credential $cred

Instytead of getting a session, I get:

PS C:\WINDOWS\system32>  New-JiraSession -Credential $cred
DEBUG: [Get-JiraConfigServer] ParameterSetName: __AllParameterSets
DEBUG: [Get-JiraConfigServer] PSBoundParameters: 
Key         Value
---         -----
ErrorAction  Stop

DEBUG: [New-JiraSession] ParameterSetName: __AllParameterSets
DEBUG: [New-JiraSession] PSBoundParameters: 
Key        Value                                    
---        -----                                    
Credential System.Management.Automation.PSCredential

DEBUG: [Invoke-JiraMethod] ParameterSetName: __AllParameterSets
DEBUG: [Invoke-JiraMethod] PSBoundParameters: 
Key          Value                                                    
---          -----                                                    
Credential   System.Management.Automation.PSCredential                
Method       Get                                                      
Headers      {}                                                       
URI          https://<my Jira Service Desk site>/rest/api/2/mypermissions
StoreSession True                                                     

Resolve-DefaultParameterValue : Cannot bind argument to parameter 'Reference' because it is null.
At C:\Program Files\WindowsPowerShell\Modules\JiraPS\2.12.4\JiraPS.psm1:3215 char:78
+ ... ultParameterValue -Reference $global:PSDefaultParameterValues -Comman ...
+                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Resolve-DefaultParameterValue], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Resolve-DefaultParameterValue

Cannot index into a null array.
At C:\Program Files\WindowsPowerShell\Modules\JiraPS\2.12.4\JiraPS.psm1:3222 char:9
+         $_headers = Join-Hashtable -Hashtable $script:DefaultHeaders, ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArray

You cannot call a method on a null-valued expression.
At C:\Program Files\WindowsPowerShell\Modules\JiraPS\2.12.4\JiraPS.psm1:3266 char:13
+         if ($_headers.ContainsKey("Content-Type")) {
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

DEBUG: [Test-ServerResponse] Investigating $InputObject.Headers['X-Seraph-LoginReason']
DEBUG: [New-JiraSession] Adding session result to existing module PrivateData

I get the same error with simple commands like those below:

 get-jiraissue -key "ITHD-4" -Credential $cred
 Get-JiraProject

In working with Atlassian support, I was able to connect to the REST API with my ID and token for a password. So I know I have the right data. What am I doing wrong or is their a bug?

DavidHromyk commented 4 years ago

What are you using for credentials?

rschmidt2 commented 4 years ago

My login account and the token

lipkau commented 4 years ago

please make sure you are using the latest version. I released a new version yesterday.

also: try using the email address instead of the username

rschmidt2 commented 4 years ago

Now I am getting this error with this code:

PS C:\WINDOWS\system32> Write-Host "Logging into Jira API" -ForegroundColor Cyan
           $Global:signinName = cat c:\scripts\adminuser.txt
           $Global:pass = cat c:\scripts\JIRASec.pwd | convertto-securestring
           $Global:cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $signinName, $pass
           New-JiraSession -Credential $Global:cred
Logging into Jira API
Invoke-JiraMethod : **The 'permissions' query parameter is required.**
At C:\Program Files\WindowsPowerShell\Modules\JiraPS\2.12.4\JiraPS.psm1:3890 char:19
+         $result = Invoke-JiraMethod @parameter
+                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidResult: (:) [Invoke-JiraMethod], RuntimeException
    + FullyQualifiedErrorId : InvalidResponse.Status400,Invoke-JiraMethod
lipkau commented 4 years ago

you are not on the latest version of the module

update-module jiraps
import-module jiraps -force

version should be 2.12.5

rschmidt2 commented 4 years ago

THANKS!!!! That did it.

rschmidt2 commented 4 years ago

It was working and I am using the 2.12.5 version. I put in the email address and the token password. I get: PS C:\WINDOWS\system32> New-JiraSession -Credential (Get-Credential)

cmdlet Get-Credential at command pipeline position 1 Supply values for the following parameters: DEBUG: [Get-JiraConfigServer] ParameterSetName: __AllParameterSets DEBUG: [Get-JiraConfigServer] PSBoundParameters: Key Value


ErrorAction Stop

DEBUG: [New-JiraSession] ParameterSetName: __AllParameterSets DEBUG: [New-JiraSession] PSBoundParameters: Key Value


Credential System.Management.Automation.PSCredential

DEBUG: [Invoke-JiraMethod] ParameterSetName: __AllParameterSets DEBUG: [Invoke-JiraMethod] PSBoundParameters: Key Value


Credential System.Management.Automation.PSCredential Method Get Headers {} URI https://titanpro2.atlassian.net/rest/api/2/myself StoreSession True

Resolve-DefaultParameterValue : Cannot bind argument to parameter 'Reference' because it is null. At C:\Program Files\WindowsPowerShell\Modules\JiraPS\2.12.5\JiraPS.psm1:3215 char:78

Cannot index into a null array. At C:\Program Files\WindowsPowerShell\Modules\JiraPS\2.12.5\JiraPS.psm1:3222 char:9

You cannot call a method on a null-valued expression. At C:\Program Files\WindowsPowerShell\Modules\JiraPS\2.12.5\JiraPS.psm1:3266 char:13

DEBUG: [Test-ServerResponse] Investigating $InputObject.Headers['X-Seraph-LoginReason'] DEBUG: [New-JiraSession] Adding session result to existing module PrivateData

Any ideas?

[image: Titan-Pro-Logo_Email-Signature.png]

Randy Schmidt

IT and System Integration Manager, Titan Pro SCI

P: 641.231.8958

randalschmidt@titanprosci.com | www.titanprosci.com

On Wed, Nov 27, 2019 at 1:37 PM Oliver Lipkau notifications@github.com wrote:

you are not on the latest version of the module

update-module jirapsimport-module jiraps -force

version should be 2.12.5

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AtlassianPS/JiraPS/issues/389?email_source=notifications&email_token=ANQ4MGPE44ZD4346M5ZXIYDQV3D5ZA5CNFSM4JMIP2I2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFKRRQY#issuecomment-559225027, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANQ4MGNIEVXEBNLWVELUWMTQV3D5ZANCNFSM4JMIP2IQ .