gahh 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/gahh.rb +10 -0
- data/lib/gahh/api_scope_parser.rb +15 -0
- data/lib/gahh/handler.rb +40 -0
- metadata +61 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a4c9880350355318938dedd4e066156f5e6d8649
|
4
|
+
data.tar.gz: 9c6bec92a9c6ba2a2c216948d8b674ad018d4881
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3a9cff85cee37d2084f2c5b1b0654ba89002cedf28418ad6430f14d667a7c51ea233dc3660ef37e2f80a617200307c757b0129cbb5f0c3a4c06b7aba25e03479
|
7
|
+
data.tar.gz: f2b2aa96a90e6e0f7a9c4074b0943665e5cff6c4b25cc7db54b29ccee151f300ad2391440754e4eebe667ee5f6826ec5121863bdf19ef43a8d909e4f840fa0ac
|
data/lib/gahh.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module Gahh
|
2
|
+
|
3
|
+
module ApiScopeParser
|
4
|
+
|
5
|
+
def self.testing_method(word)
|
6
|
+
puts "testing with #{word}"
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.convert_api_scope_to_uri(api_scope)
|
10
|
+
return "https://www.googleapis.com/auth/#{api_scope[:api]}.readonly" if api_scope[:scope] == "read"
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
data/lib/gahh/handler.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
class Gahh::Handler
|
2
|
+
|
3
|
+
def self.testing_def(param)
|
4
|
+
puts "testing with parameter #{param}"
|
5
|
+
end
|
6
|
+
|
7
|
+
def initialize(options)
|
8
|
+
@client_id = options[:client_id]
|
9
|
+
@client_secret = options[:client_secret]
|
10
|
+
@redirect_uri = options[:redirect_uri]
|
11
|
+
end
|
12
|
+
|
13
|
+
def retrieve_auth(scopes)
|
14
|
+
# options expecting scopes organized in hash with api and expectation
|
15
|
+
# ie {"analytics" => "read"}
|
16
|
+
|
17
|
+
scope = Gah::ApiScopeParser::convert_api_scope_to_uri(scopes)
|
18
|
+
|
19
|
+
client = Signet::OAuth2::Client.new(
|
20
|
+
:authorization_uri => 'https://accounts.google.com/o/oauth2/auth',
|
21
|
+
:token_endpoint_uri => 'https://accounts.google.com/o/oauth2/token',
|
22
|
+
:client_id => @client_id,
|
23
|
+
:client_secret => @client_secret,
|
24
|
+
:scope => scope,
|
25
|
+
:redirect_uri => @redirect_uri
|
26
|
+
)
|
27
|
+
return client.authorization_uri.to_s
|
28
|
+
end
|
29
|
+
|
30
|
+
def request_access_token(auth_code)
|
31
|
+
http = Net::HTTP.new('accounts.google.com', 443)
|
32
|
+
path = '/o/oauth2/token'
|
33
|
+
http.use_ssl = true
|
34
|
+
data = "code=#{auth_code}&client_id=#{@client_id}&client_secret=#{@client_secret}&redirect_uri=#{@redirect_uri}&grant_type=authorization_code"
|
35
|
+
response = http.post(path, data)
|
36
|
+
values = JSON.parse(response.body)
|
37
|
+
binding.pry
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gahh
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yaniv Savir
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: signet
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: A tool to better use and interact with Google API, including offline
|
28
|
+
access
|
29
|
+
email: saviry@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- lib/gahh.rb
|
35
|
+
- lib/gahh/handler.rb
|
36
|
+
- lib/gahh/api_scope_parser.rb
|
37
|
+
homepage: http://rubygems.org/gems/gahh
|
38
|
+
licenses:
|
39
|
+
- MIT
|
40
|
+
metadata: {}
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
requirements: []
|
56
|
+
rubyforge_project:
|
57
|
+
rubygems_version: 2.1.11
|
58
|
+
signing_key:
|
59
|
+
specification_version: 4
|
60
|
+
summary: Google API Help and Handling
|
61
|
+
test_files: []
|