One of the interesting bits of the Goplan API is that it uses OAuth to authenticate users and authorize data access from applications. OAuth lets you, the developer, focus on your application entirely while the user feels secure because his login information never changes hands. For more information about how OAuth works, check out the OAuth website.
Currently there are OAuth implementations in all major programming languages including Ruby, PHP, Python, Java, Javascript, and C#. Click here for a list of implementations and code examples. The examples below use the Ruby OAuth gem, but they should be simple enough to follow with any of the other existing libraries.
First we include the OAuth gem using Rubygems
require 'rubygems'
gem 'oauth'
require 'oauth'
After the gem has been loaded, we instantiate a new Consumer, and ask for a request token. Note that the url has no trailing slash
consumer = OAuth::Consumer.new "CONSUMER_KEY", "CONSUMER_SECRET", { :site => "http://www.goplanapp.com" }
request = consumer.get_request_token
Having the request token ready, we can use it to generate an authorization URL. The end user can access this URL to authorize our application access to our data, without ever giving our third party application his/her login information.
request.authorize_url
=> "http://{company alias}.goplanapp.com/oauth/authorize?oauth_token=XxXxXxXxXxXxXxXxX"
Once the user has accessed the URL returned above and authorized the application we can use our request instance to get the authorized access token from Goplan.
access = request.get_access_token
Having the authorized access token, you are now free to use the methods from the Goplan API. The access token has all the standard Ruby HTTP methods available, and the get command returns a standard ruby http response you can process and use.
response = access.get "API METHOD ENDPOINT"
Follow us on Twitter and Facebook. Talk to us and Get Satisfaction.
Goplan is a product of Webreakstuff | Contact support | Terms of Service