Module: Nexmo::JWT
- Extended by:
- T::Sig
- Defined in:
- lib/nexmo/jwt.rb
Class Method Summary collapse
Class Method Details
.generate(payload, private_key) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/nexmo/jwt.rb', line 37 def self.generate(payload, private_key) payload[:iat] = iat = Time.now.to_i unless payload.key?(:iat) || payload.key?('iat') payload[:exp] = T.must(iat) + 60 unless payload.key?(:exp) || payload.key?('exp') payload[:jti] = SecureRandom.uuid unless payload.key?(:jti) || payload.key?('jti') private_key = OpenSSL::PKey::RSA.new(private_key) unless private_key.respond_to?(:sign) ::JWT.encode(payload, private_key, 'RS256') end |