I am trying to connect to my company's confluence space by using the ConfluencePS but I cannot seem to authenticate my account.
I have created an PAT on both Atlassian.net and directly on the Data Center that Confluence is hosted on. Neither seem to work.
The URI is set up in the format "https://confl.CompanyName.com".
The code I am using to attempt to connect is shown below.
Import-Module ConfluencePS
$Username = 'first.last@mycompany.com'
$Password = 'full_token_string' | ConvertTo-SecureString -AsPlainText -Force
$Credentials = New-Object System.Management.Automation.PsCredential($Username,$Password)
Set-ConfluenceInfo -BaseURI 'https://confl.CompanyName.com' -Credential $Credentials
Get-ConfluenceSpace -SpaceKey '####'
When this runs, I receive back a 401: UNAUTHORIZED error
I've also tried for the password, the token name, the Atlassian token, the password to my account, the token on the data center. I can't seem to find what is expecting.
Can ConfluencePS work on Data Center based Confluence pages? How can I go about using this?
@Brendan ,
You can try first if Authentication works using other method like CURL or HTTPIE or Postman, etc. just to be sure that the user/password and the encoded password work. For authentication you can use headers as { "Authentication": "Basic {base64encodedPassword}"}.
Powershell simple GET to check auth:
$cred = Get-Credential
Invoke-WebRequest -Uri 'https://confl.CompanyName.com/rest/api/content' -Credential $cred
Invoke-WebRequest -Method Get -Uri 'https://confl.CompanyName.com/rest/api/content' -Authentication Basic
other clis:
https -a user:pass https://confl.CompanyName.com/rest/api/content
curl -X user:pass https://confl.CompanyName.com/rest/api/content
https -a user:pass https://confl.CompanyName.com/rest/api/content
Thanks for the answer, it seems like I am able to reach the API when using the Invoke-WebRequest or curl methods but when I try to do anything with the ConfluencePS module, I still am seeing the 401 error. Image attached for reference.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Brendan ,
It needs more deep debugging of what is the cause in code. Maybe it would be better to contact the team of ConfuencePS:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
like this?
Import-Module ConfluencePS
$Username = '************@gmail.com'
#generate a key from here https://id.atlassian.com/manage-profile/security/api-tokens
$Key = '******************************************' `
| ConvertTo-SecureString -AsPlainText -Force
$Credentials = New-Object System.Management.Automation.PsCredential($Username,$Key)
#Set-ConfluenceInfo -BaseURI 'https://********.atlassian.net/wiki' -Credential $Credentials
Get-ConfluenceSpace
#https://***********.atlassian.net/wiki/spaces/~712020e628e2b3818645efb1b64e5371f102bc/pages/294914/page+1
Get-ConfluencePage -PageID 294914 | Format-List * #get page info including content
#get space ley from it's url
$pages = Get-ConfluencePage -SpaceKey "~712020e628e2b3818645efb1b64e5371f102bc"
$pages | ForEach-Object { $_.Body } #gets page content as HTML
Gist https://gist.github.com/tristian2/c33692cbe46e287dd4f9bd5bb887ddb5
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.