auth

package
v0.0.0-...-9797080 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2015 License: BSD-3-Clause Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	URLs = map[string]string{
		"RequestUrl":      "%s/v3/oauth/request",
		"RequestTokenUrl": "%s/auth/authorize?request_token=%s&redirect_uri=%s",
		"RequestAuthUrl":  "%s/v3/oauth/authorize",
	}
)

Functions

This section is empty.

Types

type Auth

type Auth struct {
	Authenticator
	DeviceControllable
	// contains filtered or unexported fields
}

func Factory

func Factory(consumerKey, redirectURI string) (*Auth, *utils.RequestError)

func New

func New(consumerKey, redirectURI string, request utils.HttpRequest) (*Auth, *utils.RequestError)

Creates new getpocket auth instance consumerKey is available at http://getpocket.com/developers, redirectURI must include full URL

func (*Auth) Connect

func (a *Auth) Connect() (string, *utils.RequestError)

Connect to GP API using the consumerKey

func (*Auth) RequestPermissions

func (a *Auth) RequestPermissions(requestToken string, w http.ResponseWriter, r *http.Request)

Request GP API for permissions

func (*Auth) SetForceMobile

func (a *Auth) SetForceMobile(forceMobile bool)

@see http://getpocket.com/developer/docs/authentication

func (*Auth) User

func (a *Auth) User(requestToken string) (*PocketUser, *utils.RequestError)

Make final authentication and retrieve user details (username, access_token)

type Authenticated

type Authenticated interface {
	AccessToken() string
}

type Authenticator

type Authenticator interface {
	RequestPermissions(requestToken string, w http.ResponseWriter, r *http.Request)
	Connect() (string, *utils.RequestError)
	User(requestToken string) (*PocketUser, *utils.RequestError)
}

Authentication methods to connect and use GetPocket API

type DeviceControllable

type DeviceControllable interface {
	SetForceMobile(forceMobile bool)
}

Optional device settings when using GetPocket API

type PocketUser

type PocketUser struct {
	PAccessToken string `json:"access_token"`
	PUsername    string `json:"username"`
}

func NewUser

func NewUser() *PocketUser

func (*PocketUser) AccessToken

func (u *PocketUser) AccessToken() string

func (*PocketUser) SetAccessToken

func (u *PocketUser) SetAccessToken(accessToken string) *PocketUser

func (*PocketUser) SetUsername

func (u *PocketUser) SetUsername(username string) *PocketUser

func (*PocketUser) Username

func (u *PocketUser) Username() string

type User

type User interface {
	Username() string
}

Jump to

Keyboard shortcuts

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