https://github.com/electrofocus/telegram-auth-verifier
Go package for Telegram Login credentials verification
https://github.com/electrofocus/telegram-auth-verifier
auth authentication credentials credentials-verification crypto go golang telegram telegram-authorization verification verifier
Last synced: 12 days ago
JSON representation
Go package for Telegram Login credentials verification
- Host: GitHub
- URL: https://github.com/electrofocus/telegram-auth-verifier
- Owner: electrofocus
- License: mit
- Created: 2021-03-18T16:45:19.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2023-11-06T17:27:24.000Z (about 2 years ago)
- Last Synced: 2024-06-19T10:10:29.347Z (over 1 year ago)
- Topics: auth, authentication, credentials, credentials-verification, crypto, go, golang, telegram, telegram-authorization, verification, verifier
- Language: Go
- Homepage:
- Size: 11.7 KB
- Stars: 7
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# telegram-auth-verifier
[](https://pkg.go.dev/github.com/electrofocus/telegram-auth-verifier)
## About
Here's the Go package for [Telegram Website Login](https://core.telegram.org/widgets/login#checking-authorization) credentials verification.
This package uses [semantic versioning v2.0.0](https://semver.org/spec/v2.0.0.html), so you can be sure of backward compatibility of API.
## Install
With a [correctly configured](https://golang.org/doc/install#testing) Go toolchain run:
```
go get github.com/electrofocus/telegram-auth-verifier
```
## Example
Let's verify credentials:
```go
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](https://play.golang.org/p/Pw2v8h4gbo1).