Documentation ¶
Overview ¶
Package oauth1a implements the OAuth 1.0a specification.
Index ¶
- func Rfc3986Escape(input string) string
- type ClientConfig
- type HmacSha1Signer
- func (s *HmacSha1Signer) GetOAuthParams(request *http.Request, clientConfig *ClientConfig, userConfig *UserConfig, ...) (map[string]string, string, error)
- func (s *HmacSha1Signer) GetSignature(consumerSecret string, tokenSecret string, signatureBase string) string
- func (s *HmacSha1Signer) Sign(request *http.Request, clientConfig *ClientConfig, userConfig *UserConfig) error
- type Service
- type Signer
- type UserConfig
- func (c *UserConfig) GetAccessToken(ctx context.Context, token string, verifier string, service *Service, ...) error
- func (c *UserConfig) GetAuthorizeURL(service *Service) (string, error)
- func (c *UserConfig) GetRequestToken(ctx context.Context, service *Service, client *http.Client) error
- func (c *UserConfig) GetToken() (string, string)
- func (c *UserConfig) ParseAuthorize(request *http.Request, service *Service) (string, string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Rfc3986Escape ¶
Rfc3986Escape 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.
Types ¶
type ClientConfig ¶
ClientConfig is a container for client-specific configuration related to the OAuth process. This struct is intended to be serialized and stored for future use.
type HmacSha1Signer ¶
type HmacSha1Signer struct{}
HmacSha1Signer is a signer which implements the HMAC-SHA1 signing algorithm.
func (*HmacSha1Signer) GetOAuthParams ¶
func (s *HmacSha1Signer) GetOAuthParams(request *http.Request, clientConfig *ClientConfig, userConfig *UserConfig, nonce string, timestamp string) (map[string]string, string, error)
GetOAuthParams 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 ¶
func (s *HmacSha1Signer) GetSignature(consumerSecret string, tokenSecret string, signatureBase string) string
GetSignature calculates the HMAC-SHA1 signature of a base string, given a consumer and token secret.
func (*HmacSha1Signer) Sign ¶
func (s *HmacSha1Signer) Sign(request *http.Request, clientConfig *ClientConfig, userConfig *UserConfig) error
Sign adds the appropriate OAuth Authorization header to given an unsigned request using the HMAC-SHA1 algorithm.
type Service ¶
type Service struct { RequestURL string AuthorizeURL string AccessURL string *ClientConfig Signer }
Service represents an API which offers OAuth access.
type Signer ¶
type Signer interface {
Sign(request *http.Request, config *ClientConfig, user *UserConfig) error
}
Signer interface for any OAuth signing implementations.
type UserConfig ¶
type UserConfig struct { RequestTokenSecret string RequestTokenKey string AccessTokenSecret string AccessTokenKey string Verifier string AccessValues url.Values }
UserConfig is a 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 ¶
func NewAuthorizedConfig(token string, secret string) *UserConfig
NewAuthorizedConfig 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 ¶
func (c *UserConfig) GetAccessToken(ctx context.Context, token string, verifier string, service *Service, client *http.Client) error
GetAccessToken issues a request to exchange the current request token for an access token.
func (*UserConfig) GetAuthorizeURL ¶
func (c *UserConfig) GetAuthorizeURL(service *Service) (string, error)
GetAuthorizeURL obtains a URL which will allow the current user to authorize access to their OAuth-protected data.
func (*UserConfig) GetRequestToken ¶
func (c *UserConfig) GetRequestToken(ctx context.Context, service *Service, client *http.Client) error
GetRequestToken issues a request to obtain a Request token.
func (*UserConfig) GetToken ¶
func (c *UserConfig) GetToken() (string, string)
GetToken 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 ¶
func (c *UserConfig) ParseAuthorize(request *http.Request, service *Service) (string, string, error)
ParseAuthorize parses an access token and verifier from a redirected authorize request.