You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been using this module for some time in the past, but now I'm writing a new application that should send pushover notifications, and I keep getting errors saying application token is invalid, and I don't understand why.
I have tried to set API tokens that I know are working (and are currently in use by other applications), into my own code, as well as the example code in the readme for this repo, neither of these work and the error response from app.SendMessage is application token is invalid in both cases.
Has the pushover API changed, or is there something else going on here? I'm on go 1.18, tried on 1.17 with the same results.
If I go to the Pushover web UI I can successfully send messages to my new application / api token.
I also tried the cli applicationt ntfy which can send pushover messages, I set it to use my new api token and sent a message successfully. Judging from this it seems that either my Go setup or this module has a bug somewhere causing this error.
I am dumbfounded by how the below example code with my tokens returns the error mentioned above.
It would be great to begin by verifying that this code is still working with the module v1.1.0.
package main
import (
"log"
"github.com/gregdel/pushover"
)
func main() {
// Create a new pushover app with a token
app := pushover.New(<my known working user token>)
// Create a new recipient
recipient := pushover.NewRecipient(<my known working api token>)
// Create the message to send
message := pushover.NewMessage("Hello !")
// Send the message to the recipient
response, err := app.SendMessage(message, recipient)
if err != nil {
log.Panic(err)
}
// Print the response if you want
log.Println(response)
}
The text was updated successfully, but these errors were encountered:
The New function takes the API token and the NewRecipient function takes the user token. From the example of code above, it seems that you did it the other way around.
Can you try swapping the two tokens an try again ?
Ah yes, this is the case, I swapped them. I was under the impression that pushover.New sets up a new object to manage the messages sent by my user key, and pushover.Recipient defines which of my applications to send to, I'd forgotten how this worked since setting it up last time a few years ago.
I assume that it's set up the way it is in order to be able to send to multiple user keys from the same api token.
Why I didn't just try swapping them yesterday is beyond me, I must have been incredibly tired...
I've been using this module for some time in the past, but now I'm writing a new application that should send pushover notifications, and I keep getting errors saying
application token is invalid
, and I don't understand why.I have tried to set API tokens that I know are working (and are currently in use by other applications), into my own code, as well as the example code in the readme for this repo, neither of these work and the error response from
app.SendMessage
isapplication token is invalid
in both cases.Has the pushover API changed, or is there something else going on here? I'm on go 1.18, tried on 1.17 with the same results.
If I go to the Pushover web UI I can successfully send messages to my new application / api token.
I also tried the cli applicationt
ntfy
which can send pushover messages, I set it to use my new api token and sent a message successfully. Judging from this it seems that either my Go setup or this module has a bug somewhere causing this error.I am dumbfounded by how the below example code with my tokens returns the error mentioned above.
It would be great to begin by verifying that this code is still working with the module v1.1.0.
The text was updated successfully, but these errors were encountered: