auth

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CoinbaseBaseURL is the base url of the coinbase api
	CoinbaseBaseURL = "https://api.coinbase.com/"
	// APIVersion is the api version used in this package
	APIVersion = "2017-06-02"
)

Variables

View Source
var (
	// CoinbaseAPIKey is your api key obtained from your coinbase account setting
	CoinbaseAPIKey = os.Getenv("COINBASE_APIKEY")
	// CoinbaseAPISecret is your api secret obtained from your coinbase account settings
	CoinbaseAPISecret = os.Getenv("COINBASE_APISECRET")
	// CBAccount is the exported singleton to use this package in code
	CBAccount *APIKeyAuthentication
)

Functions

This section is empty.

Types

type APIKeyAuthentication

type APIKeyAuthentication struct {
	Key     string
	Secret  string
	BaseURL string
	Client  http.Client
}

APIKeyAuthentication Struct implements the Authentication interface and takes care of authenticating RPC requests for clients with the `CoinbaseAPIKey` & `CoinbaseAPISecret` pair

func NewClient

func NewClient(pubkey *string, privkey *string) *APIKeyAuthentication

NewClient return a new client against a pub and priv key pairs

func (APIKeyAuthentication) Authenticate

func (a APIKeyAuthentication) Authenticate(req *http.Request, endpoint string, params []byte) error

Authenticate with API Key + Secret authentication requires a request header of the HMAC SHA-256 signature of the "message" as well as an incrementing nonce and the API key

The CB-ACCESS-SIGN header is generated by creating a sha256 HMAC using the secret key on the prehash string timestamp + method + requestPath + body

The timestamp value is the same as the CB-ACCESS-TIMESTAMP header.

The CB-ACCESS-TIMESTAMP header MUST be number of seconds since Unix Epoch.

func (APIKeyAuthentication) GetBaseURL

func (a APIKeyAuthentication) GetBaseURL() string

GetBaseURL return the coinbase api base URL

func (APIKeyAuthentication) GetClient

func (a APIKeyAuthentication) GetClient() *http.Client

GetClient return the authenticated http client

Jump to

Keyboard shortcuts

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