fix token as SecureString

This commit is contained in:
James 2022-03-12 22:15:09 +00:00
parent d6ce1b196e
commit c93a9f614c
1 changed files with 4 additions and 3 deletions

View File

@ -1,9 +1,9 @@
<#
.Synopsis
Login and retrieve an Access token.
Login and retrieve an Access token (returned as a SecureString).
.Description
Login and retrieve an Access token from _matrix/client/v3/login. See https://spec.matrix.org/v1.2/client-server-api/#post_matrixclientv3login.
Login and retrieve an Access token from _matrix/client/v3/login (returned as a SecureString). See https://spec.matrix.org/v1.2/client-server-api/#post_matrixclientv3login.
.Parameter ServerUrl
URL for the Matrix server to log into, for example "https://matrix.example.com".
@ -35,11 +35,12 @@ function Get-MatrixLoginToken {
}
type = "m.login.password"
password = $Credentials.Password | ConvertFrom-SecureString -AsPlainText
initial_device_display_name = "PSMatrix"
} | ConvertTo-Json
$res = Invoke-RestMethod -Uri "$ServerUrl/$apiPath" -Method $apiMethod -Body $reqBody
$token = $res.access_token | ConvertTo-SecureString
$token = $res.access_token | ConvertTo-SecureString -AsPlainText
return $res.access_token
}