auth

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScopeNotifications = "sellingpartnerapi::notifications"
	ScopeMigration     = "sellingpartnerapi::migration"
	ScopeOrders        = "sellingpartnerapi::orders"
	ScopeInventory     = "sellingpartnerapi::inventory"
	ScopeProducts      = "sellingpartnerapi::products"
	ScopePricing       = "sellingpartnerapi::pricing"
	ScopeFeeds         = "sellingpartnerapi::feeds"
	ScopeReports       = "sellingpartnerapi::reports"
	ScopeFinances      = "sellingpartnerapi::finances"
	ScopeShipping      = "sellingpartnerapi::shipping"
	ScopeMessaging     = "sellingpartnerapi::messaging"
	ScopeSolicitations = "sellingpartnerapi::solicitations"
)

ScopeConstants defines common scope constants

Variables

This section is empty.

Functions

This section is empty.

Types

type LWAAccessTokenCache

type LWAAccessTokenCache interface {
	Get(key string) (string, bool)
	Set(key, value string, ttl time.Duration)
	Delete(key string)
}

LWAAccessTokenCache represents the interface for caching access tokens

type LWAAccessTokenRequestMeta

type LWAAccessTokenRequestMeta struct {
	GrantType    string `json:"grant_type"`
	RefreshToken string `json:"refresh_token,omitempty"`
	ClientID     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
	Scope        string `json:"scope,omitempty"`
}

LWAAccessTokenRequestMeta represents the metadata for LWA access token request

type LWAAccessTokenResponse

type LWAAccessTokenResponse struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token,omitempty"`
	TokenType    string `json:"token_type"`
	ExpiresIn    int    `json:"expires_in"`
	Scope        string `json:"scope,omitempty"`
}

LWAAccessTokenResponse represents the response from LWA token endpoint

type LWAAuthorizationCredentials

type LWAAuthorizationCredentials struct {
	ClientID     string
	ClientSecret string
	RefreshToken string
	Endpoint     string
	Scopes       []string
}

LWAAuthorizationCredentials represents the credentials for LWA authorization

type LWAAuthorizationSigner

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

LWAAuthorizationSigner handles signing requests with LWA access tokens

func NewLWAAuthorizationSigner

func NewLWAAuthorizationSigner(credentials *LWAAuthorizationCredentials) *LWAAuthorizationSigner

NewLWAAuthorizationSigner creates a new LWA authorization signer

func NewLWAAuthorizationSignerWithCache

func NewLWAAuthorizationSignerWithCache(credentials *LWAAuthorizationCredentials, cache LWAAccessTokenCache) *LWAAuthorizationSigner

NewLWAAuthorizationSignerWithCache creates a new LWA authorization signer with cache

func (*LWAAuthorizationSigner) GetLwaClient

func (l *LWAAuthorizationSigner) GetLwaClient() *LWAClient

GetLwaClient returns the LWA client

func (*LWAAuthorizationSigner) SetCache

func (l *LWAAuthorizationSigner) SetCache(cache LWAAccessTokenCache)

SetCache sets the token cache

func (*LWAAuthorizationSigner) Sign

func (l *LWAAuthorizationSigner) Sign(req *http.Request) error

Sign adds the authorization header to the request

type LWAClient

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

LWAClient handles Login with Amazon (LWA) authentication

func NewLWAClient

func NewLWAClient(endpoint string) *LWAClient

NewLWAClient creates a new LWA client

func (*LWAClient) GetAccessToken

func (l *LWAClient) GetAccessToken(meta *LWAAccessTokenRequestMeta) (string, error)

GetAccessToken retrieves an access token, using cache if available

func (*LWAClient) GetEndpoint

func (l *LWAClient) GetEndpoint() string

GetEndpoint returns the LWA endpoint

func (*LWAClient) SetCache

func (l *LWAClient) SetCache(cache LWAAccessTokenCache)

SetCache sets the token cache

func (*LWAClient) SetClient

func (l *LWAClient) SetClient(client *http.Client)

SetClient allows setting a custom HTTP client

type MemoryCache

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

MemoryCache implements LWAAccessTokenCache using in-memory storage

func NewMemoryCache

func NewMemoryCache() *MemoryCache

NewMemoryCache creates a new memory cache with default settings

func NewMemoryCacheWithTTL

func NewMemoryCacheWithTTL(defaultTTL, cleanupInterval time.Duration) *MemoryCache

NewMemoryCacheWithTTL creates a new memory cache with custom TTL

func (*MemoryCache) Delete

func (m *MemoryCache) Delete(key string)

Delete removes a value from cache

func (*MemoryCache) Flush

func (m *MemoryCache) Flush()

Flush clears all items from cache

func (*MemoryCache) Get

func (m *MemoryCache) Get(key string) (string, bool)

Get retrieves a value from cache

func (*MemoryCache) ItemCount

func (m *MemoryCache) ItemCount() int

ItemCount returns the number of items in cache

func (*MemoryCache) Set

func (m *MemoryCache) Set(key, value string, ttl time.Duration)

Set stores a value in cache with TTL

type RateLimitConfiguration

type RateLimitConfiguration struct {
	ID     string `json:"id"`
	Policy string `json:"policy"`
	Limit  int    `json:"limit"`
	Rate   struct {
		Interval string `json:"interval"`
		Amount   int    `json:"amount"`
	} `json:"rate"`
}

RateLimitConfiguration represents rate limiting configuration

Jump to

Keyboard shortcuts

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