Documentation ¶
Overview ¶
Package twitter provides Twitter OAuth1 login, callback, and token handlers.
Index ¶
- Variables
- func CallbackHandler(config *oauth1.Config, success, failure ctxh.ContextHandler) ctxh.ContextHandler
- func LoginHandler(config *oauth1.Config, failure ctxh.ContextHandler) ctxh.ContextHandler
- func TokenHandler(config *oauth1.Config, success, failure ctxh.ContextHandler) ctxh.ContextHandler
- func UserFromContext(ctx context.Context) (*twitter.User, error)
- func WithUser(ctx context.Context, user *twitter.User) context.Context
Constants ¶
This section is empty.
Variables ¶
var ( ErrMissingToken = fmt.Errorf("twitter: missing token field %s", accessTokenField) ErrMissingTokenSecret = fmt.Errorf("twitter: missing token field %s", accessTokenSecretField) )
Errors for missing token or token secret form fields.
var (
ErrUnableToGetTwitterUser = errors.New("twitter: unable to get Twitter User")
)
Twitter login errors
Functions ¶
func CallbackHandler ¶
func CallbackHandler(config *oauth1.Config, success, failure ctxh.ContextHandler) ctxh.ContextHandler
CallbackHandler handles Twitter callback requests by parsing the oauth token and verifier and adding the Twitter access token and User to the ctx. If authentication succeeds, handling delegates to the success handler, otherwise to the failure handler.
func LoginHandler ¶
func LoginHandler(config *oauth1.Config, failure ctxh.ContextHandler) ctxh.ContextHandler
LoginHandler handles Twitter login requests by obtaining a request token and redirecting to the authorization URL.
func TokenHandler ¶
func TokenHandler(config *oauth1.Config, success, failure ctxh.ContextHandler) ctxh.ContextHandler
TokenHandler receives a Twitter access token/secret and calls Twitter verify_credentials to get the corresponding User. If successful, the access token/secret and User are added to the ctx and the success handler is called. Otherwise, the failure handler is called.
func UserFromContext ¶
UserFromContext returns the Twitter User from the ctx.
Types ¶
This section is empty.