Install Auth SDK
This guide explains how to configure the Wristband SDK in a Go application that uses the standard net/http package. standard net/http Handlers.
Installation
Install the Wristband Auth SDK using the Go CLI:
go get github.com/wristband-dev/go-authConfiguration the SDK
Prerequisites
Before configuring the SDK, retrieve the following credentials:
WRISTBAND_APPLICATION_VANITY_DOMAINWRISTBAND_CLIENT_IDWRISTBAND_CLIENT_SECRET
If you completed the Set Up a Wristband Application guide, these values were provided when your application was provisioned.
If you do not have them, follow the guide to retrieve them from the Wristband Dashboard.
Implementation steps
To configure Wristband in your Go project:
- Import the Wristband Go Auth SDK.
- Configure
AuthConfigwith your client and domain details. - Instantiate
WristbandAuth.Disabling secure cookies in local developmentBy default,
WristbandAuthcreates secure cookies that are only sent over HTTPS. Most browsers allow secure cookies over HTTP for http://localhost, but some browsers, including Safari, block them even onlocalhost.To disable secure cookies during local development, use the
WithDangerouslyDisableSecureCookiesauth config option. Re-enable secure cookies before deploying to production.
// main.go
package main
import (
"github.com/wristband-dev/go-auth"
)
func main() {
// Initialize the Wristband Auth configuration
cfg := goauth.NewAuthConfig(
"<WRISTBAND_CLIENT_ID>",
"<WRISTBAND_CLIENT_SECRET>",
"<WRISTBAND_APPLICATION_VANITY_DOMAIN>",
)
wristbandAuth, err := cfg.WristbandAuth()
if err != nil {
// Handle error
}
}// main.go
package main
import (
"github.com/wristband-dev/go-auth"
)
func main() {
// Initialize the Wristband Auth configuration
cfg := goauth.NewAuthConfig(
"<WRISTBAND_CLIENT_ID>",
"<WRISTBAND_CLIENT_SECRET>",
"<WRISTBAND_APPLICATION_VANITY_DOMAIN>",
goauth.WithDangerouslyDisableSecureCookies(),
)
wristbandAuth, err := cfg.WristbandAuth()
if err != nil {
// Handle error
}
}Updated 4 days ago
What’s Next
Next, we’ll add session middleware to manage authenticated user sessions.