Documentation ¶
Overview ¶
Package digits provides Digits (Phone) OAuth1 login and token handlers.
Index ¶
- Variables
- func AccountFromContext(ctx context.Context) (*digits.Account, error)
- func EchoFromContext(ctx context.Context) (string, string, error)
- func LoginHandler(config *Config, success, failure http.Handler) http.Handler
- func TokenHandler(config *oauth1.Config, success, failure http.Handler) http.Handler
- func WithAccount(ctx context.Context, account *digits.Account) context.Context
- func WithEcho(ctx context.Context, endpoint, header string) context.Context
- type Config
Constants ¶
This section is empty.
Variables ¶
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
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 ¶
AccountFromContext returns the Digits Account from the ctx.
func EchoFromContext ¶
EchoFromContext returns the Digits echo endpoint and header from the ctx.
func LoginHandler ¶
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 ¶
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 ¶
WithAccount returns a copy of ctx that stores the Digits Account.