oauth1

package
Version: v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2014 License: MIT, Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const OOB = "oob"

Out-Of-Band mode, used for applications that do not have a callback URL, such as mobile phones or command-line utilities.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessToken

type AccessToken struct {
	// contains filtered or unexported fields
}

AccessToken represents a value used by the Consumer to gain access to the Protected Resources on behalf of the User, instead of using the User's Service Provider credentials.

func NewAccessToken

func NewAccessToken(token, secret string, params map[string]string) *AccessToken

NewAccessToken returns a new instance of AccessToken with the specified token, secret and additional parameters.

func ParseAccessToken

func ParseAccessToken(reader io.ReadCloser) (*AccessToken, error)

ParseAccessToken parses the URL-encoded query string from the Reader and returns an AccessToken.

func ParseAccessTokenStr

func ParseAccessTokenStr(str string) (*AccessToken, error)

ParseAccessTokenStr parses the URL-encoded query string and returns an AccessToken.

func (*AccessToken) Encode

func (a *AccessToken) Encode() string

Encode encodes the values into “URL encoded” form of the AccessToken. e.g. "oauth_token=foo&oauth_token_secret=baz"

func (*AccessToken) Params

func (a *AccessToken) Params() map[string]string

Gets any additional parameters, as defined by the Service Provider.

func (*AccessToken) Secret

func (a *AccessToken) Secret() string

Gets the oauth_token_secret value

func (*AccessToken) Token

func (a *AccessToken) Token() string

Gets the oauth_token value

type Consumer

type Consumer struct {
	// A value used by the Consumer to identify itself
	// to the Service Provider.
	ConsumerKey string

	// A secret used by the Consumer to establish
	// ownership of the Consumer Key.
	ConsumerSecret string

	// An absolute URL to which the Service Provider will redirect
	// the User back when the Obtaining User Authorization step
	// is completed.
	//
	// If the Consumer is unable to receive callbacks or a callback
	// URL has been established via other means, the parameter
	// value MUST be set to oob (case sensitive), to indicate
	// an out-of-band configuration.
	CallbackURL string

	// The URL used to obtain an unauthorized
	// Request Token.
	RequestTokenURL string

	// The URL used to obtain User authorization
	// for Consumer access.
	AccessTokenURL string

	// The URL used to exchange the User-authorized
	// Request Token for an Access Token.
	AuthorizationURL string
}

Consumer represents a website or application that uses the OAuth 1.0a protocol to access protected resources on behalf of a User.

func (*Consumer) AuthorizeRedirect

func (c *Consumer) AuthorizeRedirect(t *RequestToken) (string, error)

AuthorizeRedirect constructs the request URL that should be used to redirect the User to verify User identify and consent.

func (*Consumer) AuthorizeToken

func (c *Consumer) AuthorizeToken(t *RequestToken, verifier string) (*AccessToken, error)

func (*Consumer) RequestToken

func (c *Consumer) RequestToken() (*RequestToken, error)

func (*Consumer) Sign

func (c *Consumer) Sign(req *http.Request, token Token) error

Sign will sign an http.Request using the provided token.

func (*Consumer) SignParams

func (c *Consumer) SignParams(req *http.Request, token Token, params map[string]string) error

Sign will sign an http.Request using the provided token, and additional parameters.

type RequestToken

type RequestToken struct {
	// contains filtered or unexported fields
}

RequestToken represents a value used by the Consumer to obtain authorization from the User, and exchanged for an Access Token.

func ParseRequestToken

func ParseRequestToken(reader io.ReadCloser) (*RequestToken, error)

ParseRequestToken parses the URL-encoded query string from the Reader and returns a RequestToken.

func ParseRequestTokenStr

func ParseRequestTokenStr(str string) (*RequestToken, error)

ParseRequestTokenStr parses the URL-encoded query string and returns a RequestToken.

func (*RequestToken) Encode

func (r *RequestToken) Encode() string

Encode encodes the values into “URL encoded” form of the ReqeustToken. e.g. "oauth_token=foo&oauth_token_secret=baz"

func (*RequestToken) Secret

func (r *RequestToken) Secret() string

Gets the oauth_token_secret value

func (*RequestToken) Token

func (r *RequestToken) Token() string

Gets the oauth_token value

type Token

type Token interface {
	Token() string  // Gets the oauth_token value.
	Secret() string // Gets the oauth_token_secret.
	Encode() string // Encode encodes the token into “URL encoded” form.
}

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