Nexmo JWT Generator for Ruby

Gem Version Build Status Coverage StatusContributor Covenant

Nexmo is now known as Vonage

This is the Ruby library to generate Nexmo JSON Web Tokens (JWTs). To use it you'll need a Nexmo account. Sign up for free at nexmo.com.

Requirements

The JWT generator supports Ruby version 2.5 or newer.

Installation

To install the Ruby client library using Rubygems:

gem install nexmo-jwt

Alternatively you can clone the repository:

git clone git@github.com:Nexmo/nexmo-jwt-ruby.git

Usage

By default the Nexmo JWT generator creates a short lived JWT (15 minutes) per request. To generate a long lived JWT for multiple requests, specify a longer value in the exp parameter in the claims object.

claims = {
  application_id: application_id,
  nbf: 1483315200,
  exp: 1514764800,
  iat: 1483228800
}

private_key = File.read('path/to/private.key')

token = NexmoJwt::Generator.generate(claims, private_key)

Documentation

Nexmo Ruby JWT documentation: https://www.rubydoc.info/github/nexmo/nexmo-jwt

Nexmo Ruby code examples: https://github.com/Nexmo/nexmo-ruby-code-snippets

Nexmo API reference: https://developer.nexmo.com/api

License

This library is released under the MIT License