AtlassianPS / ConfluencePS

Confluence REST API (including Cloud) via PowerShell
https://AtlassianPS.org/module/ConfluencePS
MIT License
150 stars 41 forks source link

Need instructions for authenticating to Confluence Cloud #203

Open bkolodny opened 2 years ago

bkolodny commented 2 years ago

Authenticating to confluence cloud is different than to an on prem server, and I and others do not know how to do it in ConfluencePS.

Instructions on how to do it should be added to the help.

awsles commented 2 years ago

The documentation on authenticatiin is very poor (here). If your organization uses Single Sign-on, then you cannot use Get-Credential to obtain a credential for ConfluencePS or JiraPS. Furthermore, there is ZERO documentaion on how to use an API token for ConfluencePS or JiraPS. As far as I can see, it sadly does not appear possible.

If using an API token is possible, then somene please post an example (with ALL steps). For example, with Get-ConfluenceSpace.

therealscottcarlow commented 1 year ago

Get-Credential works with with SSO... You just don't use your password but a personal API token for the password field (obtainable via https://id.atlassian.com/manage-profile/security/api-tokens). Example:

$creds = get-credential
Set-ConfluenceInfo -Credential $creds -BaseURI "https://your-domain/atlasssian.net/wiki"

Also for those using Powershell 7 like me, where Get-Credentials is kinda gimped, I build the credential object in my scripts the old fashioned way.

$api_key = ConvertTo-SecureString <api_key> -AsPlainText -Force
$username = <username>
$creds = New-Object System.Management.Automation.PSCredential ($username, $api_key)