-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_token.ps1
More file actions
27 lines (21 loc) · 1.12 KB
/
get_token.ps1
File metadata and controls
27 lines (21 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# test get new token
#[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::TLS -bor [Net.SecurityProtocolType]::TLS11 -bor [Net.SecurityProtocolType]::TLS12
[Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor [System.Net.SecurityProtocolType]::Tls12
if(!$BearerToken){
$BearerToken = (Get-Content -Path '~/.jiratoken/token')
}
#$BearerToken | write-debug
$Headers = @{
"Authorization" = "Bearer $BearerToken"
"Content-Type" = "application/json"
"Accept" = "application/json"
}
#$headers | write-debug
$postParams = '{ "name": "tokenName", "expirationDuration": 90 }'
#$postParams | write-debug
$tokenInfo = Invoke-RestMethod -Method GET -Uri https://acorelli.atlassian.net/rest/pat/latest/tokens -Headers $Headers
#$tokenInfo.expiringAt | write-host
#$token = Invoke-WebRequest -Uri https://acorelli.atlassian.net/rest/pat/latest/tokens -Method POST -Headers $Headers -Body $postParams
$token = Invoke-RestMethod -Method POST -Uri https://acorelli.atlassian.net/rest/pat/latest/tokens -Headers $Headers -Body $postParams
#$token | write-host
$token.rawToken | write-host