Here's the Go package for Telegram Website Login credentials verification.
This package uses semantic versioning v2.0.0, so you can be sure of backward compatibility of API.
With a correctly configured Go toolchain run:
go get github.com/electrofocus/telegram-auth-verifier
Let's verify credentials:
package main
import (
"encoding/json"
"fmt"
tgverifier "github.com/electrofocus/telegram-auth-verifier"
)
func main() {
var (
token = []byte("Your Telegram Bot Token")
creds tgverifier.Credentials
)
rawCreds := `{
"id": 111111111,
"first_name": "John",
"last_name": "Doe",
"username": "johndoe",
"auth_date": 1615974774,
"hash": "ae1b08443b7bb50295be3961084c106072798cb65e91995a1b49927cd4cc5b0c"
}`
json.Unmarshal([]byte(rawCreds), &creds)
if err := creds.Verify(token); err != nil {
fmt.Println("Credentials are not from Telegram")
return
}
fmt.Println("Credentials are from Telegram")
}
Open above example in The Go Playground.