Giter VIP home page Giter VIP logo

oauth-client's Introduction

Generic OAuth Client for Ruby, based on moomerman/twitter_oauth

NOTE: This is a very early version and has not been tested, give it some time :)

This is a core OAuth Client, extracting core elements from the an awesome moomerman/twitter_oauth gem and reorganizing them to give you tools to build your own client for an API of choice. This gem can be used to jump-start your new OAuth client.

Example:

require 'oauth_client'	
class TwitterOAuth < OAuthClient::Client
  site 'http://twitter.com'
end

That’s all you need to have a working OAuth client which you can use to authorize with an OAuth server. Of course, it won’t do anything just yet :) You need to implement specific methods for the API you’re working with.

You have a few helper methods to ease the trouble. OAuthClient#get and OAuthClient#post return the unparsed response from the server. It includes an adapter for JSON, which will parse the response prior to returning it. To use it, call OAuthClient#json.get or OAuthClient#json.post.

See this example from moomerman/twitter_oauth:

module TwitterOauth
  class Client
    [...]
    def user(page=1)
      oauth_response = access_token.get("/statuses/user_timeline.json?page=#{page}")
      JSON.parse(oauth_response.body)
    end
		[...]
  end
end

with OAuthClient, it would look like this:

require 'oauth_client'	
class TwitterOAuth < OAuthClient::Client
  site 'http://twitter.com'

  def user(page=1)
    json.get("/statuses/user_timeline.json?page=#{page}")
  end
end

Authors

This gem has been built by hacking and modifing the twitter_oauth gem by Richard Taylor (http://github.com/moomerman). The core client authorization structure is taken from there.

Banged together by Marcin Bunsch (http://github.com/marcinbunsch).

oauth-client's People

Contributors

moomerman avatar trek avatar precision avatar ndmarcel avatar dirceu-jr avatar luccastera avatar cicloid avatar

Stargazers

Marcel Jackwerth avatar Masafumi Fujiwara avatar

Watchers

Masafumi Fujiwara avatar Marcel Jackwerth avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.