oauth

package
v0.0.0-...-ba7cdbd Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2014 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package oauth implements a oAuth 1.0a client.

Index

Constants

This section is empty.

Variables

View Source
var (
	NoRedirectAllowedError = errors.New("redirects not allowed with oAuth")
)

Functions

func Base

func Base(method string, url string, values url.Values) string

Base returns the signature base string for the given input parameters.

func Sign

func Sign(base string, clientSecret string, tokenSecret string) string

Sign returns the HMAC-SHA1 signature with the given signature base and secrets.

Types

type Consumer

type Consumer struct {
	Key              string
	Secret           string
	Service          string
	RequestTokenURL  string
	AccessTokenURL   string
	AuthorizationURL string
	CallbackURL      string
	Client           *httpclient.Client
	// contains filtered or unexported fields
}

func (*Consumer) Authorization

func (c *Consumer) Authorization() (string, *Token, error)

Authorization requests a Request Token and returns the URL the user should visit to authorize it as well as the token, which needs to be used later for exchanging it for an Access Token.

func (*Consumer) Clone

func (c *Consumer) Clone(ctx httpclient.Context) *Consumer

func (*Consumer) Exchange

func (c *Consumer) Exchange(token *Token, verifier string) (*Token, error)

Exchange exchanges a Request Token for an Access Token using the given verifier. The verifier is sent by the provider to the consumer at the callback URL. If the provider you're using doesn't require a verifier, just pass an empty string.

func (*Consumer) Get

func (c *Consumer) Get(url string, values url.Values, token *Token) (*httpclient.Response, error)

Get performs a GET request to the given URL with the given values and signed with the consumer and the given token (if any). The url parameter can't contain a query string. All url parameters should be passed using the values parameter.

func (*Consumer) Post

func (c *Consumer) Post(url string, values url.Values, token *Token) (*httpclient.Response, error)

Post performs a POST request to the given URL with the given values and signed with the given token (if any).

func (*Consumer) Request

func (c *Consumer) Request(method string, url string, values url.Values, token *Token) (*http.Request, error)

Request returns a *http.Request with the given method, url and values, which is already signed using the given token (if any).

func (*Consumer) SendRequest

func (c *Consumer) SendRequest(method string, url string, values url.Values, token *Token) (*httpclient.Response, error)

SendRequest works like Requests, but it also sends the request and returns an *http.Response.

type Token

type Token struct {
	Key    string
	Secret string
}

Jump to

Keyboard shortcuts

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