twitter

package
v2.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: MIT Imports: 8 Imported by: 6

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

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

Functions

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.

Types

This section is empty.

Jump to

Keyboard shortcuts

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