appstoreconnectjwt

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2019 License: MIT Imports: 9 Imported by: 0

README

AppStoreConnect-JWT-Go

License godoc Build Status Coverage Status Go Report Card

AppStoreConnect-JWT-Go is a Go package that provides an easy way generate JWT token needed for accessing AppStoreConnect API. This package handles token reuse (returns same token if previously issued token was not expired) and is thread safe.

AppStoreConnect JWT Token requirements.

Example

main.go

        client, err := jwt.New(cfg)
	if err != nil {
		panic(err)
	}

	tokenString, err := client.BearerToken()
	if err != nil {
		panic(err)
	}

	fmt.Println(tokenString)

Result:

$ go run example/main.go
eyJhbGciOiJFUzI1NiIsImtpZCI6IjJYOVI0SFhGMzQiLCJ0eXAiOiJKV1QifQ.eyJhdWQiOiJhcHBzdG9yZWNvbm5lY3QtdjEiLCJleHAiOjE1NjQ1OTQ0NzEsImlhdCI6MTU2NDU5Mzg3MSwiaXNzIjoiNTcyNDY1NDItOTZmZS0xYTYzLWUwNTMtMDgyNGQwMTEwNzJhIn0.Tpqv1ZoDcv7CsDaq4ZF8bycN3hJexYrBQbzsUEd6hNV94bQ_gIES1nsCDlF9-JMrWlT7sa
1ET2kZcWBezfUe5w

Todo

  • A few more tests
  • Remove dependency on jwt-go package
  • Document more code

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPrivateKeyNotValidPEM   = errors.New("pk is not a valid PEM type")
	ErrPrivateKeyNotValidPKCS8 = errors.New("pk must be a encoded PKCS#8 type")
	ErrPrivateKeyNotECDSA      = errors.New("pk must be of ECDSA type")
	ErrConfigIsNil             = errors.New("config is nil")
)

Functions

This section is empty.

Types

type Client

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

func New

func New(cfg *Config) (*Client, error)

New is a constructor that creates new client with valid jwt token.

func (*Client) BearerToken

func (c *Client) BearerToken() (string, error)

BearerToken returns a signed JWT token for AppStoreConnect. This method handles token reuse.

type Config

type Config struct {
	ISS string
	KID string
	// ExpiresIn defines when the token should expire.
	// It is AppStore's responsibility to enforce token expiration check.
	// This field is only used to set `exp` field in Claims
	// defined at https://tools.ietf.org/html/rfc7519#section-4.1.4.
	//
	// This field should not be set more than 20 minutes in the future
	// for AppStore to consider it valid.
	ExpiresIn time.Duration
	AUD       string
	PK        string
}

type ReaderLength

type ReaderLength interface {
	Read(b []byte) (n int, err error)
	Len() int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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