oauth

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2019 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package oauth only oAuth 1.0

Index

Constants

View Source
const (
	OAUTH_VERSION          = "1.0"
	HTTP_AUTH_HEADER       = "Authorization"
	OAUTH_HEADER           = "OAuth "
	BODY_HASH_PARAM        = "oauth_body_hash"
	CALLBACK_PARAM         = "oauth_callback"
	CONSUMER_KEY_PARAM     = "oauth_consumer_key"
	NONCE_PARAM            = "oauth_nonce"
	SESSION_HANDLE_PARAM   = "oauth_session_handle"
	SIGNATURE_METHOD_PARAM = "oauth_signature_method"
	SIGNATURE_PARAM        = "oauth_signature"
	TIMESTAMP_PARAM        = "oauth_timestamp"
	TOKEN_PARAM            = "oauth_token"
	TOKEN_SECRET_PARAM     = "oauth_token_secret"
	VERIFIER_PARAM         = "oauth_verifier"
	VERSION_PARAM          = "oauth_version"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessToken

type AccessToken struct {
	Token  string
	Secret string
}

AccessToken AccessToken

type OAuth

type OAuth struct {
	ServiceProvider *ServiceProvider
	// contains filtered or unexported fields
}

OAuth OAuth

func NewOAuth

func NewOAuth(consumerKey, consumerSecret string, serviceProvider ServiceProvider) *OAuth

NewOAuth NewOAuth

func NewOAuthWithClient

func NewOAuthWithClient(consumerKey, consumerSecret string, serviceProvider ServiceProvider, client *http.Client) *OAuth

NewOAuthWithClient NewOAuthWithClient

func (*OAuth) BuildClient

func (o *OAuth) BuildClient(accessToken *AccessToken) *http.Client

BuildClient build client with oauth

func (*OAuth) GetAccessToken

func (o *OAuth) GetAccessToken(ctx context.Context, token RequestToken, verificationCode string, additionalParams map[string]string) (*AccessToken, error)

GetAccessToken token 只是授权此 requestToken,需要用此 token 换取 AccessToken

func (*OAuth) GetAuthorizationURL

func (o *OAuth) GetAuthorizationURL(token *RequestToken) (string, error)

GetAuthorizationURL 请求用户授权Request Token

https://github.com/FanfouAPI/FanFouAPIDoc/wiki/Oauth#%E8%AF%B7%E6%B1%82%E7%94%A8%E6%88%B7%E6%8E%88%E6%9D%83request-token

type RequestToken

type RequestToken struct {
	Token  string
	Secret string
}

RequestToken RequestToken

type RoundTripper

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

RoundTripper Custom RoundTripper

func (*RoundTripper) RoundTrip

func (r *RoundTripper) RoundTrip(userRequest *http.Request) (*http.Response, error)

RoundTrip RoundTrip

type ServiceProvider

type ServiceProvider struct {
	RequestTokenURL   string
	AuthorizeTokenURL string
	AccessTokenURL    string
	CallBackURL       string
}

ServiceProvider ServiceProvider

Jump to

Keyboard shortcuts

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