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-auth

Configuration the SDK

Prerequisites

Before configuring the SDK, retrieve the following credentials:

  • WRISTBAND_APPLICATION_VANITY_DOMAIN
  • WRISTBAND_CLIENT_ID
  • WRISTBAND_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:

  1. Import the Wristband Go Auth SDK.
  2. Configure AuthConfig with your client and domain details.
  3. Instantiate WristbandAuth.
    📘

    Disabling secure cookies in local development

    By default, WristbandAuth creates 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 on localhost.

    To disable secure cookies during local development, use the WithDangerouslyDisableSecureCookies auth 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
  }
}

What’s Next

Next, we’ll add session middleware to manage authenticated user sessions.

Did this page help you?