Version: v2.1.0+incompatible Latest Latest

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

Go to latest
Published: Nov 20, 2018 License: MIT Imports: 8 Imported by: 19



Package twitter provides Twitter OAuth1 login, callback, and token handlers.



This section is empty.


View Source
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.

View Source
var (
	ErrUnableToGetTwitterUser = errors.New("twitter: unable to get Twitter User")

Twitter login errors


func CallbackHandler

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

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 http.Handler) http.Handler

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 http.Handler) http.Handler

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

func UserFromContext(ctx context.Context) (*twitter.User, error)

UserFromContext returns the Twitter User from the ctx.

func WithUser

func WithUser(ctx context.Context, user *twitter.User) context.Context

WithUser returns a copy of ctx that stores the Twitter User.


This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL