google_oauth 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.textile +5 -0
- data/lib/google_oauth/calendar.rb +7 -0
- data/lib/google_oauth/client.rb +65 -0
- data/lib/google_oauth/contacts.rb +7 -0
- data/lib/google_oauth.rb +7 -0
- metadata +105 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) Richard Taylor
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.textile
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'google_oauth/contacts'
|
2
|
+
require 'google_oauth/calendar'
|
3
|
+
|
4
|
+
module GoogleOAuth
|
5
|
+
class Client
|
6
|
+
|
7
|
+
def initialize(options = {})
|
8
|
+
@application_id = options[:application_id]
|
9
|
+
@application_secret = options[:application_secret]
|
10
|
+
@callback = options[:callback]
|
11
|
+
@token = options[:token]
|
12
|
+
end
|
13
|
+
|
14
|
+
def authorize_url(options = {})
|
15
|
+
options[:scope] ||= 'https://www.google.com/m8/feeds/'
|
16
|
+
consumer.web_server.authorize_url(
|
17
|
+
:redirect_uri => options[:callback] || @callback,
|
18
|
+
:scope => options[:scope]
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
def authorize(options = {})
|
23
|
+
@access_token ||= consumer.web_server.get_access_token(
|
24
|
+
options[:code],
|
25
|
+
:redirect_uri => options[:callback] || @callback
|
26
|
+
)
|
27
|
+
@token = @access_token.token
|
28
|
+
@access_token
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
def consumer
|
33
|
+
@consumer ||= OAuth2::Client.new(
|
34
|
+
@application_id,
|
35
|
+
@application_secret,
|
36
|
+
{
|
37
|
+
:site => "https://accounts.google.com",
|
38
|
+
:authorize_url => '/o/oauth2/auth',
|
39
|
+
:access_token_url => '/o/oauth2/token'
|
40
|
+
}
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
def access_token
|
45
|
+
OAuth2::AccessToken.new(consumer, @token)
|
46
|
+
end
|
47
|
+
|
48
|
+
def _get(url, params={})
|
49
|
+
oauth_response = access_token.get(url, params)
|
50
|
+
JSON.parse(oauth_response) rescue oauth_response
|
51
|
+
end
|
52
|
+
|
53
|
+
def _post(url, params={}, headers={})
|
54
|
+
oauth_response = access_token.post(url, params, headers)
|
55
|
+
puts oauth_response.inspect
|
56
|
+
JSON.parse(oauth_response) rescue oauth_response
|
57
|
+
end
|
58
|
+
|
59
|
+
def _delete(url)
|
60
|
+
oauth_response = access_token.delete(url)
|
61
|
+
JSON.parse(oauth_response) rescue oauth_response
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
data/lib/google_oauth.rb
ADDED
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: google_oauth
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Richard Taylor
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-05-03 00:00:00 +01:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: oauth2
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 0.0.8
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
prerelease: false
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 1.1.9
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: shoulda
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: "0"
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: mocha
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
type: :development
|
59
|
+
version_requirements: *id004
|
60
|
+
description: google_oauth is a OAuth2 Ruby client library for the Google Data APIs
|
61
|
+
email: moomerman@gmail.com
|
62
|
+
executables: []
|
63
|
+
|
64
|
+
extensions: []
|
65
|
+
|
66
|
+
extra_rdoc_files: []
|
67
|
+
|
68
|
+
files:
|
69
|
+
- LICENSE
|
70
|
+
- README.textile
|
71
|
+
- lib/google_oauth.rb
|
72
|
+
- lib/google_oauth/calendar.rb
|
73
|
+
- lib/google_oauth/client.rb
|
74
|
+
- lib/google_oauth/contacts.rb
|
75
|
+
has_rdoc: true
|
76
|
+
homepage: http://github.com/moomerman/google_oauth
|
77
|
+
licenses: []
|
78
|
+
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options:
|
81
|
+
- --inline-source
|
82
|
+
- --charset=UTF-8
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: "0"
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
none: false
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: "0"
|
97
|
+
requirements: []
|
98
|
+
|
99
|
+
rubyforge_project: google_oauth
|
100
|
+
rubygems_version: 1.5.0
|
101
|
+
signing_key:
|
102
|
+
specification_version: 2
|
103
|
+
summary: google_oauth is a OAuth2 Ruby client library for the Google Data APIs
|
104
|
+
test_files: []
|
105
|
+
|