func (s *HmacSha1Signer) GetOAuthParams(request *http.Request, clientConfig *ClientConfig, userConfig *UserConfig, nonce string, timestamp string) (map[string]string, string, error) {
	oauthParams := map[string]string{
		"oauth_consumer_key":     clientConfig.ConsumerKey,
		"oauth_nonce":            nonce,
		"oauth_signature_method": "HMAC-SHA1",
		"oauth_timestamp":        timestamp,
		"oauth_version":          "1.0",
	}
	tokenKey, tokenSecret := userConfig.GetToken()
	if tokenKey != "" {
		oauthParams["oauth_token"] = tokenKey
	}
	signingParams := request.URL.Query()
	for key, value := range oauthParams {
		signingParams.Set(key, value)
	}
	if request.Body != nil && request.Header.Get("Content-Type") == "application/x-www-form-urlencoded" {
		if err := request.ParseForm(); err != nil {
			return nil, "", err
		}
		for key, values := range request.Form {
			for _, v := range values {
				signingParams.Add(key, v)
			}
		}
		body := strings.NewReader(request.Form.Encode())
		request.Body = ioutil.NopCloser(body)
		request.ContentLength = int64(body.Len())
	}
	signingURL := fmt.Sprintf("%v://%v%v", request.URL.Scheme, request.URL.Host, request.URL.Path)
	signatureParts := []string{
		request.Method,
		url.QueryEscape(signingURL),
		url.QueryEscape(sortedQueryString(signingParams)),
	}
	signatureBase := strings.Join(signatureParts, "&")
	oauthParams["oauth_signature"] = s.GetSignature(clientConfig.ConsumerSecret, tokenSecret, signatureBase)
	return oauthParams, signatureBase, nil
}
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.
package oauth1a
import (
	"bytes"
	"crypto/hmac"
	"crypto/rand"
	"crypto/sha1"
	"encoding/base64"
	"encoding/hex"
	"fmt"
	"io"
	"io/ioutil"
	"net/http"
	"net/url"
	"sort"
	"strings"
	"time"
)
const (
	errBodyLimit = 1024
)
type ClientConfig struct {
	ConsumerSecret string
	ConsumerKey    string
	CallbackURL    string
}
type Service struct {
	RequestURL   string
	AuthorizeURL string
	AccessURL    string
	*ClientConfig
	Signer
}
func (s *Service) Sign(request *http.Request, userConfig *UserConfig) error {
	return s.Signer.Sign(request, s.ClientConfig, userConfig)
}
type Signer interface {
	Sign(request *http.Request, config *ClientConfig, user *UserConfig) error
}
type HmacSha1Signer struct{}
func (HmacSha1Signer) generateNonce() string {
	nonce := make([]byte, 16)
	_, err := io.ReadFull(rand.Reader, nonce)
	if err != nil {
		panic("unable to read from crypto/rand.Reader; process is insecure: " + err.Error())
	}
	return hex.EncodeToString(nonce)
}
func (HmacSha1Signer) generateTimestamp() int64 {
	return time.Now().UTC().Unix()
}