File: README.rdoc

package info (click to toggle)
ruby-oauth 0.5.4-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 584 kB
  • sloc: ruby: 4,070; makefile: 4
file content (86 lines) | stat: -rw-r--r-- 3,163 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
= Ruby OAuth

== Status

{<img src="https://travis-ci.org/oauth-xx/oauth-ruby.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/oauth-xx/oauth-ruby]



== What

This is a RubyGem for implementing both OAuth clients and servers in Ruby applications.

See the OAuth specs http://oauth.net/core/1.0/

== Installing

  sudo gem install oauth

The source code is now hosted on the OAuth GitHub Project http://github.com/oauth-xx/oauth-ruby

== The basics

This is a ruby library which is intended to be used in creating Ruby Consumer and Service Provider applications. It is NOT a Rails plugin, but could easily be used for the foundation for such a Rails plugin.

As a matter of fact it has been pulled out from an OAuth Rails GEM (https://rubygems.org/gems/oauth-plugin https://github.com/pelle/oauth-plugin) which now uses this gem as a dependency.

== Demonstration of usage

We need to specify the oauth_callback url explicitly, otherwise it defaults to "oob" (Out of Band)

  @callback_url = "http://127.0.0.1:3000/oauth/callback"

Create a new consumer instance by passing it a configuration hash:

  @consumer = OAuth::Consumer.new("key","secret", :site => "https://agree2")

Start the process by requesting a token

  @request_token = @consumer.get_request_token(:oauth_callback => @callback_url)

  session[:token] = request_token.token
  session[:token_secret] = request_token.secret
  redirect_to @request_token.authorize_url(:oauth_callback => @callback_url)

When user returns create an access_token

  hash = { oauth_token: session[:token], oauth_token_secret: session[:token_secret]}
  request_token  = OAuth::RequestToken.from_hash(@consumer, hash)
  @access_token = @request_token.get_access_token
  @photos = @access_token.get('/photos.xml')

Now that you have an access token, you can use Typhoeus to interact with the OAuth provider if you choose.

  require 'typhoeus'
  require 'oauth/request_proxy/typhoeus_request'
  oauth_params = {:consumer => oauth_consumer, :token => access_token}
  hydra = Typhoeus::Hydra.new
  req = Typhoeus::Request.new(uri, options) # :method needs to be specified in options
  oauth_helper = OAuth::Client::Helper.new(req, oauth_params.merge(:request_uri => uri))
  req.options[:headers].merge!({"Authorization" => oauth_helper.header}) # Signs the request
  hydra.queue(req)
  hydra.run
  @response = req.response


== More Information

* RDoc: http://rdoc.info/github/oauth-xx/oauth-ruby/master/frames
* Mailing List/Google Group: http://groups.google.com/group/oauth-ruby

== How to submit patches

The source code is now hosted on the OAuth GitHub Project http://github.com/oauth-xx/oauth-ruby

To submit a patch, please fork the oauth project and create a patch with tests. Once you're happy with it send a pull request and post a message to the google group.

== License

This code is free to use under the terms of the MIT license.

== Contact

OAuth Ruby has been created and maintained by a large number of talented individuals.
The current maintainer is Aaron Quint (quirkey).

Comments are welcome. Send an email to via the OAuth Ruby mailing list http://groups.google.com/group/oauth-ruby