Class: TinyAppstoreConnect::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/tiny_appstore_connect/token.rb

Constant Summary collapse

DEFAULT_TOKEN_DURATION =

maximum expiration supported by AppStore (20 minutes) detail: developer.apple.com/documentation/appstoreconnectapi/generating_tokens_for_api_requests

10 * 60
AUDIENCE =
'appstoreconnect-v1'
ALGORITHM =
'ES256'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**kargs) ⇒ Token

Returns a new instance of Token.



19
20
21
22
23
24
# File 'lib/tiny_appstore_connect/token.rb', line 19

def initialize(**kargs)
  @duration = kargs[:duration] || DEFAULT_TOKEN_DURATION
  @issuer_id = kargs[:issuer_id]
  @key_id = kargs[:key_id]
  @private_key = handle_private_key(kargs[:private_key])
end

Instance Attribute Details

#issuer_idObject (readonly)

Returns the value of attribute issuer_id.



17
18
19
# File 'lib/tiny_appstore_connect/token.rb', line 17

def issuer_id
  @issuer_id
end

#key_idObject (readonly)

Returns the value of attribute key_id.



17
18
19
# File 'lib/tiny_appstore_connect/token.rb', line 17

def key_id
  @key_id
end

#private_keyObject (readonly)

Returns the value of attribute private_key.



17
18
19
# File 'lib/tiny_appstore_connect/token.rb', line 17

def private_key
  @private_key
end

Instance Method Details

#tokenObject



26
27
28
# File 'lib/tiny_appstore_connect/token.rb', line 26

def token
  JWT.encode(payload, private_key, ALGORITHM, header_fields)
end