add function to trim and concat homeserver url and path

This commit is contained in:
2022-03-27 15:29:44 +01:00
parent e7355a5474
commit 366bde4897
3 changed files with 15 additions and 4 deletions

View File

@ -31,7 +31,7 @@ function New-MatrixAccessToken {
[string]$DeviceDisplayName="PSMatrix"
)
$apiPath = "_matrix/client/v3/login"
$url = New-MatrixUrl -ServerUrl $ServerUrl -ApiPath "_matrix/client/v3/login"
$apiMethod = "Post"
$reqBody = @{
@ -44,7 +44,7 @@ function New-MatrixAccessToken {
initial_device_display_name = $DeviceDisplayName
} | ConvertTo-Json
$res = Invoke-RestMethod -Uri "$ServerUrl/$apiPath" -Method $apiMethod -Body $reqBody
$res = Invoke-RestMethod -Uri $url -Method $apiMethod -Body $reqBody
$token = $res.access_token | ConvertTo-SecureString -AsPlainText

View File

@ -24,7 +24,7 @@ function Remove-MatrixAccessToken {
[SecureString]$AccessToken
)
$apiPath = "_matrix/client/v3/logout"
$url = New-MatrixUrl -ServerUrl $ServerUrl -ApiPath "_matrix/client/v3/logout"
$apiMethod = "Post"
$headers = @{
@ -32,7 +32,7 @@ function Remove-MatrixAccessToken {
}
Try {
Invoke-RestMethod -Uri "$ServerUrl/$apiPath" -Method $apiMethod -Headers $headers
Invoke-RestMethod -Uri $url -Method $apiMethod -Headers $headers
return $true
}
Catch {