https://github.com/w9jds/blizzardgo
Golang package for authenticating and communicating with Blizzard's APIs
https://github.com/w9jds/blizzardgo
api blizzard golang oauth package
Last synced: 8 months ago
JSON representation
Golang package for authenticating and communicating with Blizzard's APIs
- Host: GitHub
- URL: https://github.com/w9jds/blizzardgo
- Owner: w9jds
- Created: 2019-06-01T22:05:19.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-06-07T05:18:20.000Z (about 7 years ago)
- Last Synced: 2025-08-09T07:34:54.839Z (10 months ago)
- Topics: api, blizzard, golang, oauth, package
- Language: Go
- Homepage:
- Size: 7.81 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# BlizzardGo
This library has built in functions to help you manage your sessions and requests with the Blizzard APIs.
---
## Installation
In order to start using, download it using go commandline:
```
go get github.com/w9jds/blizzardgo
```
---
## Client Authentication
If you are using just client requests for data, the token is automatically pulled when you create the client. It also refreshs the token automatically for you to make sure that it never expires.
---
## User Authentication
You can also setup a full web api handling a user login like this:
``` golang
import (
"log"
"net/http"
"os"
blizzard "github.com/w9jds/blizzardgo"
)
var (
clientID string
blizzardClient *blizzard.API
)
func main() {
clientID = os.Getenv("CLIENT_ID")
clientSecret := os.Getenv("CLIENT_SECRET")
blizzardClient = blizzard.NewClient(&blizzard.Options{
Region: "us",
ClientID: clientID,
ClientSecret: clientSecret,
RedirectURI: "http://localhost:8000/oauth",
})
http.HandleFunc("/oauth", blizzardAuth)
http.ListenAndServe(":8000", nil)
}
func blizzardAuth(writer http.ResponseWriter, request *http.Request) {
if code := request.URL.Query().Get("code"); code != "" {
token, err := blizzardClient.GetUserAccessToken(code)
if err != nil {
http.Error(writer, err.Error(), http.StatusInternalServerError)
return
}
log.Println(token)
return
}
http.Redirect(
writer,
request,
blizzardClient.GetUserAuthorizationURI("wow.profile"),
http.StatusTemporaryRedirect,
)
}
```