Wrapper gem for Infobip two factor authentication service
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib/infobip
spec
.gitignore
.rspec
.travis.yml
Gemfile
Guardfile
LICENSE
LICENSE.txt
README.md
Rakefile
infobip-twofactor.gemspec

README.md

Build Status

Gem Version

Infobip::Twofactor

Simple wrapper gem for Infobip two factor authentication service

Installation

Add this line to your application's Gemfile:

gem 'infobip-twofactor'

And then execute:

$ bundle

Or install it yourself as:

$ gem install infobip-twofactor

Usage

First of all you have to initialized application and message as described in https://2-fa.github.io/http-api.html#step-by-step-integration Then generate and store api_token for client's methods access:

require 'infobip/twofactor'

api_key = Infobip::Twofactor::API.generate_token('username', 'password')

Now you ca use it with message_id and application_id to send and verify PIN.

require 'infobip/twofactor'

@twofactor = Infobip::Twofactor::API.new("api_key", "message_id", "application_id")

@twofactor.send_pin("phone")

 => {:pinId=>"C2390DD39E0E1E39252D34BE796885FD", :to=>"48738288288", :ncStatus=>"NC_DESTINATION_UNKNOWN", :smsStatus=>"MESSAGE_SENT"}

@twofactor.verify_pin("pin")

 => {:pinId=>"C2390DD39E0E1EA9252D34BE796885FD", :msisdn=>"48738288288", :verified=>true, :attemptsRemaining=>0}

Contributing

  1. Fork it ( https://github.com/[my-github-username]/infobip-twofactor/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request