two-legged-oauth 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +4 -0
- data/README.md +25 -16
- data/lib/two-legged-oauth/access_token.rb +2 -2
- data/lib/two-legged-oauth/version.rb +1 -1
- metadata +5 -5
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -5,7 +5,8 @@
|
|
5
5
|
## Description
|
6
6
|
|
7
7
|
The purpose of this gem is to make the [oauth gem](https://github.com/oauth/oauth-ruby) play nice
|
8
|
-
with Google's custom 2 legged OAuth (2LO), used specifically for [Google Apps APIs](http://code.google.com/googleapps/)
|
8
|
+
with Google's custom 2 legged OAuth (2LO), used specifically for [Google Apps APIs](http://code.google.com/googleapps/)
|
9
|
+
accessed from [Google Apps Marketplace applications](http://code.google.com/googleapps/marketplace/).
|
9
10
|
|
10
11
|
For more info on the 2 legged OAuth see these :
|
11
12
|
|
@@ -26,39 +27,46 @@ This gem has been tested with the following libraries so far and seems to be wor
|
|
26
27
|
|
27
28
|
Add on your Gemfile :
|
28
29
|
|
29
|
-
|
30
|
+
```ruby
|
31
|
+
gem 'two-legged-oauth'
|
32
|
+
```
|
30
33
|
|
31
34
|
### By hand
|
32
35
|
|
33
36
|
On the console :
|
34
37
|
|
35
|
-
|
38
|
+
```bash
|
39
|
+
gem install two-legged-oauth
|
40
|
+
```
|
36
41
|
|
37
42
|
On your code :
|
38
43
|
|
39
|
-
|
44
|
+
```ruby
|
45
|
+
require 'two-legged-oauth'
|
46
|
+
```
|
40
47
|
|
41
48
|
## Usage
|
42
49
|
|
43
|
-
|
50
|
+
```ruby
|
51
|
+
# Create a normal consumer instance
|
52
|
+
oauth_consumer = OAuth::Consumer.new("key", "secret")
|
44
53
|
|
45
|
-
|
54
|
+
# Initialize a TwoLeggedAccessToken specifying the xoauth_requestor_id
|
55
|
+
access_token = OAuth::TwoLeggedAccessToken.new(oauth_consumer, "user@domain.com")
|
46
56
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
Pass that access token to Google Data libraries (or your custom scripts) :
|
52
|
-
|
53
|
-
g = GoogleSpreadsheet.login_with_oauth(access_token)
|
57
|
+
# Pass that access token to Google Data libraries (or your custom scripts)
|
58
|
+
gs = GoogleSpreadsheet.login_with_oauth(access_token)
|
59
|
+
```
|
54
60
|
|
55
61
|
## Internals
|
56
62
|
|
57
|
-
This thing works by rewriting the requested URL on-the-fly and appends the xoauth_requestor_id param appropriately.
|
63
|
+
This thing works by rewriting the requested URL on-the-fly and appends the xoauth_requestor_id param appropriately.
|
64
|
+
This may be dangerous at times so be aware that some well hidden bugs may come up...
|
58
65
|
|
59
66
|
## Bugs/fixes
|
60
67
|
|
61
|
-
|
68
|
+
Report any issues on the [github's issue tracker](https://github.com/fraudpointer/two-legged-oauth-ruby/issues)
|
69
|
+
or send a pull request if you have nailed the bug.
|
62
70
|
|
63
71
|
## Contributing
|
64
72
|
|
@@ -71,4 +79,5 @@ Tested contributions are always welcome! Here's what you should do:
|
|
71
79
|
|
72
80
|
# License
|
73
81
|
|
74
|
-
two-legged-oauth is copyright 2011 by [Fraudpointer](http://www.fraudpointer.com),
|
82
|
+
two-legged-oauth is copyright 2011 by [Fraudpointer](http://www.fraudpointer.com),
|
83
|
+
released under the MIT License (see LICENSE for details).
|
@@ -22,12 +22,12 @@ module OAuth
|
|
22
22
|
xoauth_param = "xoauth_requestor_id=#{xoauth_requestor_id}"
|
23
23
|
escaped_xoauth_param = "xoauth_requestor_id=#{CGI.escape(xoauth_requestor_id)}"
|
24
24
|
|
25
|
-
if request_uri.query
|
25
|
+
if request_uri.query
|
26
26
|
request_uri.query.gsub!(xoauth_param, '')
|
27
27
|
request_uri.query.gsub!(escaped_xoauth_param, '')
|
28
28
|
end
|
29
29
|
|
30
|
-
request_uri.query = request_uri.query.
|
30
|
+
request_uri.query = !request_uri.query.nil? && request_uri.query != "" ?
|
31
31
|
"#{request_uri.query}&#{escaped_xoauth_param}" :
|
32
32
|
"#{escaped_xoauth_param}"
|
33
33
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: two-legged-oauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Nikos Dimitrakopoulos
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-09-
|
18
|
+
date: 2011-09-04 00:00:00 +03:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
102
|
requirements: []
|
103
103
|
|
104
104
|
rubyforge_project: two-legged-oauth
|
105
|
-
rubygems_version: 1.
|
105
|
+
rubygems_version: 1.5.3
|
106
106
|
signing_key:
|
107
107
|
specification_version: 3
|
108
108
|
summary: Support for Google Apps 2 Legged OAuth
|