Class: AppStoreConnect::Authorization
- Inherits:
-
Object
- Object
- AppStoreConnect::Authorization
- Defined in:
- lib/app_store_connect/authorization.rb
Constant Summary collapse
- AUDIENCE =
'appstoreconnect-v1'
Instance Method Summary collapse
-
#initialize(key_id:, issuer_id:, private_key:) ⇒ Authorization
constructor
A new instance of Authorization.
- #payload ⇒ Object
- #token ⇒ Object
Constructor Details
#initialize(key_id:, issuer_id:, private_key:) ⇒ Authorization
7 8 9 10 11 |
# File 'lib/app_store_connect/authorization.rb', line 7 def initialize(key_id:, issuer_id:, private_key:) @key_id = key_id @issuer_id = issuer_id @private_key = OpenSSL::PKey.read(private_key) end |
Instance Method Details
#payload ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/app_store_connect/authorization.rb', line 13 def payload { exp: Time.now.to_i + 20 * 60, iss: @issuer_id, aud: AUDIENCE } end |
#token ⇒ Object
21 22 23 |
# File 'lib/app_store_connect/authorization.rb', line 21 def token JWT.encode(payload, @private_key, 'ES256', kid: @key_id) end |