[GH-ISSUE #869] Documentation: Powershell send with token example #610

Closed
opened 2026-05-07 00:25:51 +02:00 by BreizhHardware · 5 comments

Originally created by @jimholcomb on GitHub (Sep 6, 2023).
Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/869

In the doc for sending a message via PowerShell and using a token the doc uses this example:

# With PowerShell 7 or greater, we can use the Authentication and Token parameters
$Request = @{
  Method = "POST"
  URI = "https://ntfy.example.com/mysecrets"
  Authorization = "Bearer"
  Token = "tk_AgQdq7mVBoFD37zQVN29RhuMzNIz2"
  Body = "Look ma, with auth"
}
Invoke-RestMethod @Request

When I run this with my URI and Token I get the error: "Cannot bind parameter 'Token'. Cannot convert the "tk_AgQdq7mVBoFD37zQVN29RhuMzNIz2" value of type "System.String" to type "System.Security.SecureString"."

Changing the "Token =" line to below works for me:

Token = ConvertTo-SecureString -string "tk_AgQdq7mVBoFD37zQVN29RhuMzNIz2" -AsPlainText -Force

Originally created by @jimholcomb on GitHub (Sep 6, 2023). Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/869 In the doc for sending a message via PowerShell and using a token the doc uses this example: ``` # With PowerShell 7 or greater, we can use the Authentication and Token parameters $Request = @{ Method = "POST" URI = "https://ntfy.example.com/mysecrets" Authorization = "Bearer" Token = "tk_AgQdq7mVBoFD37zQVN29RhuMzNIz2" Body = "Look ma, with auth" } Invoke-RestMethod @Request ``` When I run this with my URI and Token I get the error: **"Cannot bind parameter 'Token'. Cannot convert the "tk_AgQdq7mVBoFD37zQVN29RhuMzNIz2" value of type "System.String" to type "System.Security.SecureString"."** Changing the "Token =" line to below works for me: `Token = ConvertTo-SecureString -string "tk_AgQdq7mVBoFD37zQVN29RhuMzNIz2" -AsPlainText -Force`
BreizhHardware 2026-05-07 00:25:51 +02:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@jimholcomb commented on GitHub (Sep 7, 2023):

Also, Authorization = Bearer should be Authentication = Bearer

<!-- gh-comment-id:1709299606 --> @jimholcomb commented on GitHub (Sep 7, 2023): Also, Authorization = Bearer should be Authentication = Bearer
Author
Owner

@binwiederhier commented on GitHub (Sep 7, 2023):

The actual header sent will be Authorization: Bearer tk_AgQdq7mVBoFD37zQVN29RhuMzNIz2, so I would have expected PowerShell to be Authorization = "Bearer tk_AgQdq7mVBoFD37zQVN29RhuMzNIz2" like in the other PowerShell examples.

Somebody else provided the PowerShell examples, so I can't really help.

Let me know what works and I will adjust the docs.

<!-- gh-comment-id:1709948652 --> @binwiederhier commented on GitHub (Sep 7, 2023): The actual header sent will be `Authorization: Bearer tk_AgQdq7mVBoFD37zQVN29RhuMzNIz2`, so I would have expected PowerShell to be `Authorization = "Bearer tk_AgQdq7mVBoFD37zQVN29RhuMzNIz2"` like in the other PowerShell examples. Somebody else provided the PowerShell examples, so I can't really help. Let me know what works and I will adjust the docs.
Author
Owner

@jimholcomb commented on GitHub (Sep 7, 2023):

Per https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-restmethod?view=powershell-7.3 the parameter is Authentication.

Under the description of that parameter it says "Bearer: Requires the Token parameter. Sends an RFC 6750 Authorization: Bearer header with the supplied token." so the parameter is one thing (Authentication) but the header it sends is another (Authorization).

<!-- gh-comment-id:1710196353 --> @jimholcomb commented on GitHub (Sep 7, 2023): Per https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-restmethod?view=powershell-7.3 the parameter is Authentication. Under the description of that parameter it says "Bearer: Requires the Token parameter. Sends an RFC 6750 Authorization: Bearer header with the supplied token." so the parameter is one thing (Authentication) but the header it sends is another (Authorization).
Author
Owner

@binwiederhier commented on GitHub (Sep 10, 2023):

@jimholcomb Would you mind creating a PR for this, or providing a fully functioning example?

<!-- gh-comment-id:1712809808 --> @binwiederhier commented on GitHub (Sep 10, 2023): @jimholcomb Would you mind creating a PR for this, or providing a fully functioning example?
Author
Owner

@binwiederhier commented on GitHub (Nov 18, 2023):

Closed due to inactivity.

<!-- gh-comment-id:1817307080 --> @binwiederhier commented on GitHub (Nov 18, 2023): Closed due to inactivity.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ntfy#610
No description provided.