Project

nexmo-jwt

0.02
Repository is archived
No release in over 3 years
Low commit activity in last 3 years
Nexmo JWT Generator for Ruby
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 2
 Project Readme

Nexmo JWT Generator for Ruby

Gem VersionCoverage StatusContributor Covenant

Nexmo is now known as Vonage

❗ This library and Ruby gem have moved! It is now vonage-jwt, located at vonage/vonage-jwt-ruby.

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
  • Installation
  • Usage
  • Documentation
  • License

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 during initialization.

Example with no custom configuration:

@builder = Nexmo::JWTBuilder.new(application_id: YOUR_APPLICATION_ID, private_key: YOUR_PRIVATE_KEY)
@token = @builder.jwt.generate

Example providing custom configuration options:

@builder = Nexmo::JWTBuilder.new(
  application_id: YOUR_APPLICATION_ID,
  private_key: YOUR_PRIVATE_KEY,
  ttl: 500,
  paths: {
    "acl": {
      "paths": {
        "/messages": {
          "methods": ["POST", "GET"],
          "filters": {
            "from": "447977271009"  
          }     
        }  
      }   
    }
  },
  subject: 'My_Custom_Subject'
)
@token = @builder.jwt.generate

Documentation

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

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

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

License

This library is released under the MIT License