Class: AppleMusic::TokenFactory

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

Overview

Class Method Summary collapse

Class Method Details

.generate(secret_key_path:, team_id:, key_id:) ⇒ Object



10
11
12
13
14
15
# File 'lib/client.rb', line 10

def self.generate(secret_key_path:, team_id:, key_id:)
  ecdsa_key = OpenSSL::PKey::EC.new File.read(secret_key_path)
  ecdsa_public = OpenSSL::PKey::EC.new ecdsa_key
  ecdsa_public.private_key = nil
  JWT.encode TokenFactory.authentication_payload(team_id), ecdsa_public, 'ES256', { kid: key_id }
end