appleoauth

package module
v0.0.0-...-b284de4 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2021 License: BSD-3-Clause Imports: 18 Imported by: 0

README

appleoauth

Go Reference

Package appleoauth provides the user/password login to Apple web service.

Reference

API Endpoints

Documentation

Overview

Package appleoauth provides the user/password login to Apple web service.

Index

Constants

View Source
const (
	// EnvIcloudUserName is the environment variable for login username to Apple web service.
	EnvIcloudUserName = "APPLE_USERNAME"

	// EnvIcloudPassword is the environment variable for login password to Apple web service.
	EnvIcloudPassword = "APPLE_PASSWORD"

	Env2FASMSDefaultPhoneNumber = "APPLEOAUTH_2FA_SMS_DEFAULT_PHONE_NUMBER"
)
View Source
const (
	HdrContentType       = "Content-Type"
	HdrXRequestedWith    = "X-Requested-With"
	HdrXAppleWidgetKey   = "X-Apple-Widget-Key"
	HdrAccept            = "Accept"
	HdrXAppleIDSessionID = "X-Apple-ID-Session-Id"
	HdrScnt              = "scnt"
)
View Source
const (
	ProtocolVersion = "QH5B2"
)

Variables

View Source
var (
	ErrInvalidUsernameOrPassword = errors.New("invalid username and password combination")
	ErrRequiredPrivacyAck        = errors.New("needs to manually sign in to https://appleid.apple.com (or https://appstoreconnect.apple.com) and acknowledge the Apple ID and Privacy agreement")
	ErrUpgradeTwoFactorAuth      = errors.New("this account is being prompted to upgrade to Two-factor authentication")
	ErrInvalidPhoneNumber        = errors.New("not a valid phone number")
	ErrNoTrustedPhoneNumbers     = errors.New("account doesn't have any trusted phone numbers, but they're required for two-factor authentication. see https://support.apple.com/en-ca/HT204915")
	ErrNotAuthenticated          = errors.New("already signed out")
	ErrUnexpectedSigninResponse  = errors.New("unexpected sign in response")
	ErrTooManyVerificationCodes  = errors.New("too many verification codes have been sent")
	ErrEmpty2FAEnv               = fmt.Errorf("%s environment variable is empty", Env2FASMSDefaultPhoneNumber)

	ErrNotImplemented = errors.New("not implemented")
)
View Source
var (
	DefaultClient = &http.Client{
		Jar: jar,
	}
)

Functions

func SetLogger

func SetLogger(l logr.Logger)

SetLogger sets logr.Logger to logger.

Types

type Account

type Account struct {
	Username string
	Password string
}

Account represents a Apple Developer account.

func (Account) Valid

func (a Account) Valid() bool

Valid reports whether the Account is valid.

type Client

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

Client represents a Apple OAuth2 client.

func NewClient

func NewClient(hc *http.Client) *Client

NewClient returns the new Client.

func (*Client) FetchOlympusSession

func (c *Client) FetchOlympusSession(ctx context.Context) error

FetchOlympusSession fetch the "itctx" from the new "olympus" (22nd May 2017) API endpoint.

func (*Client) FetchServiceKey

func (c *Client) FetchServiceKey(ctx context.Context) error

FetchServiceKey fetch serviceKey to authenticate to Apple's web service from the iTunes Connect endpoint.

func (*Client) Login

func (c *Client) Login(ctx context.Context, account *Account) error

Login logins to Apple's web service.

type ServiceError

type ServiceError struct {
	Code    string `json:"code,omitempty"`
	Title   string `json:"title,omitempty"`
	Message string `json:"message,omitempty"`
}

ServiceError represents a Apple service error.

func (ServiceError) Error

func (e ServiceError) Error() string

Error returns the string representation of a ServiceError.

Jump to

Keyboard shortcuts

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