Documentation ¶
Index ¶
Constants ¶
View Source
const ( // TokenTimeout is the period of time in seconds that a token is valid for. // If the timestamp for token issue is not within the last hour, APNs // rejects subsequent push messages. This is set to under an hour so that // we generate a new token before the existing one expires. TokenTimeout = 3000 )
Variables ¶
View Source
var ( ErrAuthKeyNotPem = errors.New("token: AuthKey must be a valid .p8 PEM file") ErrAuthKeyNotECDSA = errors.New("token: AuthKey must be of type ecdsa.PrivateKey") ErrAuthKeyNil = errors.New("token: AuthKey was nil") )
Possible errors when parsing a .p8 file.
Functions ¶
func AuthKeyFromBytes ¶
func AuthKeyFromBytes(bytes []byte) (*ecdsa.PrivateKey, error)
AuthKeyFromBytes loads a .p8 certificate from an in memory byte array and returns an *ecdsa.PrivateKey.
func AuthKeyFromFile ¶
func AuthKeyFromFile(filename string) (*ecdsa.PrivateKey, error)
AuthKeyFromFile loads a .p8 certificate from a local file and returns a *ecdsa.PrivateKey.
Types ¶
type Token ¶
type Token struct { sync.Mutex AuthKey *ecdsa.PrivateKey KeyID string TeamID string IssuedAt int64 Bearer string }
Token represents an Apple Provider Authentication Token (JSON Web Token).
func (*Token) GenerateIfExpired ¶
func (t *Token) GenerateIfExpired()
GenerateIfExpired checks to see if the token is about to expire and generates a new token.
Click to show internal directories.
Click to hide internal directories.