oauth1a: github.com/kurrik/oauth1a Index | Files

package oauth1a

import "github.com/kurrik/oauth1a"

Package oauth1a implements the OAuth 1.0a specification.

Index

Package Files

oauth1a.go userconfig.go

func Rfc3986Escape Uses

func Rfc3986Escape(input string) string

Escapes a string more in line with Rfc3986 than http.URLEscape. URLEscape was converting spaces to "+" instead of "%20", which was messing up the signing of requests.

type ClientConfig Uses

type ClientConfig struct {
    ConsumerSecret string
    ConsumerKey    string
    CallbackURL    string
}

Container for client-specific configuration related to the OAuth process. This struct is intended to be serialized and stored for future use.

type HmacSha1Signer Uses

type HmacSha1Signer struct{}

A Signer which implements the HMAC-SHA1 signing algorithm.

func (*HmacSha1Signer) GetOAuthParams Uses

func (s *HmacSha1Signer) GetOAuthParams(request *http.Request, clientConfig *ClientConfig, userConfig *UserConfig, nonce string, timestamp string) (map[string]string, string)

Returns a map of all of the oauth_* (including signature) parameters for the given request, and the signature base string used to generate the signature.

func (*HmacSha1Signer) GetSignature Uses

func (s *HmacSha1Signer) GetSignature(consumerSecret string, tokenSecret string, signatureBase string) string

Calculates the HMAC-SHA1 signature of a base string, given a consumer and token secret.

func (*HmacSha1Signer) Sign Uses

func (s *HmacSha1Signer) Sign(request *http.Request, clientConfig *ClientConfig, userConfig *UserConfig) error

Given an unsigned request, add the appropriate OAuth Authorization header using the HMAC-SHA1 algorithm.

type Service Uses

type Service struct {
    RequestURL   string
    AuthorizeURL string
    AccessURL    string
    *ClientConfig
    Signer
}

Represents an API which offers OAuth access.

func (*Service) Sign Uses

func (s *Service) Sign(request *http.Request, userConfig *UserConfig) error

Signs an HTTP request with the needed OAuth parameters.

type Signer Uses

type Signer interface {
    Sign(request *http.Request, config *ClientConfig, user *UserConfig) error
}

Interface for any OAuth signing implementations.

type UserConfig Uses

type UserConfig struct {
    RequestTokenSecret string
    RequestTokenKey    string
    AccessTokenSecret  string
    AccessTokenKey     string
    Verifier           string
    AccessValues       url.Values
}

Container for user-specific keys and secrets related to the OAuth process. This struct is intended to be serialized and stored for future use. Request and Access tokens are each stored separately, so that the current position in the auth flow may be inferred.

func NewAuthorizedConfig Uses

func NewAuthorizedConfig(token string, secret string) *UserConfig

Creates a UserConfig object with existing access token credentials. For users where an access token has been obtained through other means than the authz flows provided by this library.

func (*UserConfig) GetAccessToken Uses

func (c *UserConfig) GetAccessToken(token string, verifier string, service *Service, client *http.Client) error

Issue a request to exchange the current request token for an access token.

func (*UserConfig) GetAuthorizeURL Uses

func (c *UserConfig) GetAuthorizeURL(service *Service) (string, error)

Obtain a URL which will allow the current user to authorize access to their OAuth-protected data.

func (*UserConfig) GetRequestToken Uses

func (c *UserConfig) GetRequestToken(service *Service, client *http.Client) error

Issue a request to obtain a Request token.

func (*UserConfig) GetToken Uses

func (c *UserConfig) GetToken() (string, string)

Returns a token and secret corresponding to where in the OAuth flow this config is currently in. The priority is Access token, Request token, empty string.

func (*UserConfig) ParseAuthorize Uses

func (c *UserConfig) ParseAuthorize(request *http.Request, service *Service) (string, string, error)

Parses an access token and verifier from a redirected authorize request.

Package oauth1a imports 14 packages (graph) and is imported by 103 packages. Updated 2016-07-22. Refresh now. Tools for package owners.