https://github.com/solovev/steam_go
Simple steam auth util in golang
https://github.com/solovev/steam_go
authentication golang golang-library steam utility
Last synced: 10 days ago
JSON representation
Simple steam auth util in golang
- Host: GitHub
- URL: https://github.com/solovev/steam_go
- Owner: solovev
- Created: 2015-06-09T04:10:44.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2019-12-06T02:56:10.000Z (about 6 years ago)
- Last Synced: 2024-06-18T18:38:27.150Z (over 1 year ago)
- Topics: authentication, golang, golang-library, steam, utility
- Language: Go
- Homepage:
- Size: 6.84 KB
- Stars: 23
- Watchers: 2
- Forks: 18
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# steam_go
> Simple steam auth util
### Installation
```
$ go get github.com/solovev/steam_go
```
### Usage
Just go run main.go in example dir and open [localhost:8081/login](http://localhost:8081/login) link to see how it works
Code from ./example/main.go:
```
package main
import (
"net/http"
"github.com/solovev/steam_go"
)
func loginHandler(w http.ResponseWriter, r *http.Request) {
opId := steam_go.NewOpenId(r)
switch opId.Mode() {
case "":
http.Redirect(w, r, opId.AuthUrl(), 301)
case "cancel":
w.Write([]byte("Authorization cancelled"))
default:
steamId, err := opId.ValidateAndGetId()
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
// Do whatever you want with steam id
w.Write([]byte(steamId))
}
}
func main() {
http.HandleFunc("/login", loginHandler)
http.ListenAndServe(":8081", nil)
}
```