digits

package
v2.0.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 11, 2017 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package digits provides Digits (Phone) OAuth1 login and token handlers.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnableToGetDigitsAccount    = fmt.Errorf("digits: unable to get Digits account")
	ErrMissingAccountEndpoint      = fmt.Errorf("digits: missing OAuth Echo endpoint field")
	ErrMissingAccountRequestHeader = fmt.Errorf("digits: missing OAuth Echo header field")
	ErrInvalidDigitsEndpoint       = fmt.Errorf("digits: invalid Digits endpoint")
	ErrInvalidConsumerKey          = fmt.Errorf("digits: incorrect OAuth Echo Auth Header Consumer Key")
)

Digits login errors

View Source
var (
	ErrMissingToken       = fmt.Errorf("digits: missing Token form field %s", accessTokenField)
	ErrMissingTokenSecret = fmt.Errorf("digits: missing Token Secret form field %s", accessTokenSecretField)
)

Errors for missing token or token secret form fields.

Functions

func AccountFromContext

func AccountFromContext(ctx context.Context) (*digits.Account, error)

AccountFromContext returns the Digits Account from the ctx.

func EchoFromContext

func EchoFromContext(ctx context.Context) (string, string, error)

EchoFromContext returns the Digits echo endpoint and header from the ctx.

func LoginHandler

func LoginHandler(config *Config, success, failure http.Handler) http.Handler

LoginHandler receives a Digits OAuth Echo endpoint and OAuth header, validates the echo, and calls the endpoint to get the corresponding Digits Account. If successful, the Digits Account is added to the ctx and the success handler is called. Otherwise, the failure handler is called.

func TokenHandler

func TokenHandler(config *oauth1.Config, success, failure http.Handler) http.Handler

TokenHandler receives a Digits access token/secret and calls the Digits accounts endpoint to get the corresponding Account. If successful, the access token/secret and Account are added to the ctx and the success handler is called. Otherwise, the failure handler is called.

func WithAccount

func WithAccount(ctx context.Context, account *digits.Account) context.Context

WithAccount returns a copy of ctx that stores the Digits Account.

func WithEcho

func WithEcho(ctx context.Context, endpoint, header string) context.Context

WithEcho returns a copy of ctx that stores the Digits Echo endpoint and header.

Types

type Config

type Config struct {
	// Digits Consumer Key required to verify the OAuth Echo response.
	ConsumerKey string
	// Client to use to make the Accounts Endpoint request. If nil, then
	// http.DefaultClient is used.
	Client *http.Client
}

Config configures Digits Handlers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL