Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Gem that can be used to access the Kynetx Application Management API.
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.


Kynetx Application Manager API

A ruby api to access the Kynetx Application Manager API. The Kynetx Application Manager is a remote service that allow Kynetx developers a way to create, update , delete Kynetx KRL rulesets. This api also provides access to many other services like the Kynetx Browser Extension factory.


gem install kynetx_am_api


Getting Started

Because the Kynetx Application Manager Uses OAuth to protect its resources you as a developer must provide the required OAuth tokens for the user account you wish to access. This is fairly straight forward process.

1) First you need to acquire your consumer key and secret. To do this, please send an email to Once you have obtained your consumer key and secret you can setup OAuth with the following:

KynetxAmApi::Oauth.api_server_url = ""
KynetxAmApi::Oauth.accounts_server_url = ""
KynetxAmApi::Oauth.consumer_key = "XXXXXXXXXXXX"
KynetxAmApi::Oauth.consumer_secret= "XXXXXXXXXXXXXXXXXXXXXXXXXXX"

You can add the above settings to your Rails development.rb or production.rb files.

2) You must provide a way for the OAuth ceremony to take place. Do this in Rails by providing two actions in a controller.

def oauth_connect
  # default where we want to go to our root url.
  new_page = root_url

  # Get an instance of the Direct Kynetx Api
  api =

  # Ask the API for the authorization url.
  new_page = api.get_authorize_url

  # Get the oauth request token
  request_token = api.get_request_token

  # Save it as they are needed later
  session[:request_token] = {:request_token => request_token.token,
                               :request_secret => request_token.secret}

  # if we area already authorized to go root url or go to the authorization url
  redirect_to new_page

def authorize
  raise "Unknown OAuth Request Token" unless session[:request_token]

  rt = session[:request_token]

  # Again setup the Kynext API
  api ={:oauth_verifier => params[:oauth_verifier]}))

  # Read the the user information from the oauth session
  oauth_user = api.get_user_info

  # Here are the values you can get back from the oauth user info call
  # you store them in your own user object or what ever but you do need to track all the tokens for later
  # api calls.
  #                     :request_token => oauth_user.request_token,
  #                     :request_secret => oauth_user.request_secret,
  #                     :access_token => oauth_user.access_token,
  #                     :access_secret => oauth_user.access_secret,
  #                     :username => oauth_user.username,
  #                     :userid => oauth_user.userid,
  #                     :name =>

  redirect_to root_url

3) Once you have authorized the application you can start doing things with the api. Here are some examples

Active Record "Like" usages:

       # here attributes is the data you got back from the api.get_user_info above.
       user ={:request_token => attributes[:request_token],
           :request_secret => attributes[:request_secret]
           :oauth_verifier => attributes[:oauth_verifier]
           :access_token => attributes[:access_token]
           :access_secret => attributes[:access_secret])

# create a new application

       application = user.create_application("my app name","This is the description")
       # Save ruleset back.
       application.krl = "krl for ruleset"

Direct API Calls
       user ={:request_token => attributes[:request_token],
           :request_secret => attributes[:request_secret]
           :oauth_verifier => attributes[:oauth_verifier]
           :access_token => attributes[:access_token]
           :access_secret => attributes[:access_secret])


Copyright © 2010 Kynetx, Inc. See LICENSE for details.

Something went wrong with that request. Please try again.