Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Convert to Markdown

  • Loading branch information...
commit f7952ed19b061558150fafec010fdcf12b17df87 1 parent 66052a2
@sferik sferik authored
View
22 CHANGELOG.rdoc → CHANGELOG.md
@@ -1,22 +1,22 @@
-== 0.0.10 (June 19)
-
+0.0.10 - June 19, 2010
+----------------------
* Handle ActiveSupport JSON case where incompatible string does not raise an error. (via Flameeyes)
* Depend on latest version of MultiJSON.
-== 0.0.9 (June 18)
-
+0.0.9 - June 18, 2010
+---------------------
* Support a JSON token response with swappable JSON parser via MultiJSON.
* Add support for "expires_in" parameter and relevant methods on AccessToken.
-== 0.0.8 (April 27)
-
+0.0.8 - April 27, 2010
+----------------------
* Change get_request_token to use POST to conform to OAuth 2.0 spec. (via jeremy)
-== 0.0.7 (April 27)
-
+0.0.7 - April 27, 2010
+----------------------
* Updating Faraday dependency for improved SSL support (via technoweenie)
-== 0.0.6 (April 25)
-
+0.0.6 - April 25, 2010
+----------------------
* Added ResponseString so as not to throw away response information when making requests.
-* Deprecated #access_token on WebServer strategy in favor of #get_access_token
+* Deprecated #access_token on WebServer strategy in favor of #get_access_token
View
2  LICENSE → LICENSE.md
@@ -1,4 +1,4 @@
-Copyright (c) 2009 Intridea, Inc. and Michael Bleigh
+Copyright (c) 2011 Intridea, Inc. and Michael Bleigh
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
View
85 README.rdoc → README.md
@@ -1,48 +1,47 @@
-= OAuth2
-
+OAuth2
+======
A Ruby wrapper for the OAuth 2.0 specification. This is a work in progress, being built first to solve the pragmatic process of connecting to existing OAuth 2.0 endpoints (a.k.a. Facebook) with the goal of building it up to meet the entire specification over time.
-== Installation
-
+Installation
+------------
gem install oauth2
-== Continuous Integration
-
+Continuous Integration
+----------------------
[![Build Status](http://travis-ci.org/intridea/oauth2.png)](http://travis-ci.org/intridea/oauth2)
-== Resources
-
-* View Source on GitHub (http://github.com/intridea/oauth2)
-* Report Issues on GitHub (http://github.com/intridea/oauth2/issues)
-* Read More at the Wiki (http://wiki.github.com/intridea/oauth2/)
-
-== Web Server Example (Sinatra)
+Resources
+---------
+* View Source on GitHub (https://github.com/intridea/oauth2)
+* Report Issues on GitHub (https://github.com/intridea/oauth2/issues)
+* Read More at the Wiki (https://wiki.github.com/intridea/oauth2)
+Web Server Example (Sinatra)
+----------------------------
Below is a fully functional example of a Sinatra application that would authenticate to Facebook utilizing the OAuth 2.0 web server flow.
require 'rubygems'
require 'sinatra'
require 'oauth2'
require 'json'
-
+
def client
OAuth2::Client.new('app_id', 'app_secret', :site => 'https://graph.facebook.com')
end
-
+
get '/auth/facebook' do
redirect client.web_server.authorize_url(
:redirect_uri => redirect_uri,
:scope => 'email,offline_access'
)
end
-
+
get '/auth/facebook/callback' do
access_token = client.web_server.get_access_token(params[:code], :redirect_uri => redirect_uri)
user = JSON.parse(access_token.get('/me'))
-
user.inspect
end
-
+
def redirect_uri
uri = URI.parse(request.url)
uri.path = '/auth/facebook/callback'
@@ -51,42 +50,46 @@ Below is a fully functional example of a Sinatra application that would authenti
end
That's all there is to it! You can use the access token like you would with the
-OAuth gem, calling HTTP verbs on it etc. You can view more examples on the OAuth2
-Wiki (http://wiki.github.com/intridea/oauth2/examples)
-
-== JSON Parsing
+OAuth gem, calling HTTP verbs on it etc. You can view more examples on the [OAuth2
+Wiki](http://wiki.github.com/intridea/oauth2/examples).
+JSON Parsing
+------------
Because JSON has become the standard format of the OAuth 2.0 specification,
the <tt>oauth2</tt> gem contains a mode that will perform automatic parsing
of JSON response bodies, returning a hash instead of a string. To enable this
mode, simply add the <tt>:parse_json</tt> option to your client initialization:
- client = OAuth2::Client.new('app_id', 'app_secret',
+ client = OAuth2::Client.new(
+ 'app_id',
+ 'app_secret',
:site => 'https://example.com',
- :parse_json => true
+ :parse_json => true,
)
-
+
# Obtain an access token using the client
- token.get('/some/url.json') # {"some" => "hash"}
-
-== Testing
+ token.get('/some/url.json') #=> {"some" => "hash"}
+Testing
+-------
To use the OAuth2 client for testing error conditions do:
my_client.raise_errors = false
It will then return the error status and response instead of raising an exception.
-== Note on Patches/Pull Requests
-
-* Fork the project.
-* Make your feature addition or bug fix.
-* Add tests for it. This is important so I don't break it in a
- future version unintentionally.
-* Commit, do not mess with rakefile, version, or history.
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
-* Send me a pull request. Bonus points for topic branches.
-
-== Copyright
-
-Copyright (c) 2010 Intridea, Inc. and Michael Bleigh. See LICENSE for details.
+Note on Patches/Pull Requests
+-----------------------------
+1. Fork the project.
+2. Create a topic branch.
+3. Implement your feature or bug fix.
+4. Add documentation for your feature or bug fix.
+5. Add specs for your feature or bug fix.
+6. Run <tt>bundle exec rake spec</tt>. If your changes are not 100% covered, go back to step 5.
+7. Commit and push your changes.
+8. Submit a pull request. Please do not include changes to the [gemspec](https://github.com/intridea/oauth2/blob/master/oauth2.gemspec), [version](https://github.com/intridea/oauth2/blob/master/lib/oauth2/version.rb), or [changelog](https://github.com/intridea/oauth2/blob/master/CHANGELOG.md) file. (If you want to create your own version for some reason, please do so in a separate commit.)
+
+Copyright
+---------
+Copyright (c) 2011 Intridea, Inc. and Michael Bleigh.
+See [LICENSE](https://github.com/intridea/oauth2/blob/master/LICENSE.md) for details.
Please sign in to comment.
Something went wrong with that request. Please try again.