tumblr

package
Version: v2.1.0+incompatible Latest Latest
Warning

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

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

Documentation

Overview

Package tumblr provides Tumblr OAuth1 login and callback handlers.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnableToGetTumblrUser = errors.New("tumblr: unable to get Tumblr User")
)

Tumblr login errors

Functions

func CallbackHandler

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

CallbackHandler handles Tumblr callback requests by parsing the oauth token and verifier and adding the Tubmlr 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, cookieConfig gologin.CookieConfig, failure http.Handler) http.Handler

LoginHandler handles Tumblr login requests by obtaining a request token, setting a temporary token secret cookie, and redirecting to the authorization URL.

func WithUser

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

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

Types

type User

type User struct {
	Name      string `json:"name"`
	Following int64  `json:"following"`
	Likes     int64  `json:"likes"`
}

User is a Tumblr user.

Note that Tumblr does not provide stable user identifiers.

func UserFromContext

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

UserFromContext returns the Tumblr User from the ctx.

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