activeresource-google_spreadsheets 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0cf560b7e1ad86a01a4da5fa90b21a87be23345
|
4
|
+
data.tar.gz: a263c4f30a55a6ae8998f36fa7eea38dc2e82ce1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c31d3c6496c981452ce5de604c884ff6d4df5698db719bf448a8aac70e700a58495ad7e940b01f1ef361a2b245942941a74a46a932d7ea764051095bc45009aa
|
7
|
+
data.tar.gz: 7b1bf3cb53c7beb94d49b73abf841dbf3ad9b93b8773b134d645c6a604e60918b171c24e114b31d72c4bd12d8b431cf4a639482aaa5f661a35d20537ddb4e954
|
data/README.md
CHANGED
@@ -22,6 +22,32 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
http://webos-goodies.jp/archives/active_resource_google_spreadsheets_data_api.html
|
24
24
|
|
25
|
+
### Authorization example (Service Account)
|
26
|
+
|
27
|
+
#### 1. Using JSON key file
|
28
|
+
|
29
|
+
in `config/initializers/google_spreadsheet.rb`
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
GoogleSpreadsheets::Base.auth_type = :bearer
|
33
|
+
GoogleSpreadsheets::Base.access_token =
|
34
|
+
GoogleSpreadsheets::Auth::ServiceAccountsAccessToken.new(
|
35
|
+
json_key_io: File.open('/path/to/service_account_json_key.json')
|
36
|
+
)
|
37
|
+
```
|
38
|
+
|
39
|
+
#### 2. Using client email & private key
|
40
|
+
|
41
|
+
in `config/initializers/google_spreadsheet.rb`
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
GoogleSpreadsheets::Base.auth_type = :bearer
|
45
|
+
GoogleSpreadsheets::Base.access_token =
|
46
|
+
GoogleSpreadsheets::Auth::ServiceAccountsAccessToken.new
|
47
|
+
```
|
48
|
+
and set the values to `ENV['GOOGLE_CLIENT_EMAIL']` & `ENV['GOOGLE_PRIVATE_KEY']`
|
49
|
+
|
50
|
+
|
25
51
|
### ActiveRecord Syncing Feature (Experimental)
|
26
52
|
|
27
53
|
http://qiita.com/tkawa/items/04fc6f0574122d4a3fd2
|
@@ -18,9 +18,9 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency 'activeresource', '
|
21
|
+
spec.add_dependency 'activeresource', '>= 4.1.0'
|
22
22
|
spec.add_dependency 'activesupport'
|
23
|
-
spec.add_dependency '
|
23
|
+
spec.add_dependency 'googleauth'
|
24
24
|
|
25
25
|
spec.add_development_dependency "bundler", "~> 1.3"
|
26
26
|
spec.add_development_dependency "rake"
|
@@ -1,34 +1,17 @@
|
|
1
|
-
require '
|
2
|
-
require 'openssl'
|
1
|
+
require 'googleauth'
|
3
2
|
|
4
3
|
module GoogleSpreadsheets
|
5
4
|
module Auth
|
6
5
|
class ServiceAccountsAccessToken
|
7
6
|
def initialize(options = {})
|
8
|
-
@options = options
|
9
|
-
|
10
|
-
token_credential_uri: 'https://accounts.google.com/o/oauth2/token',
|
11
|
-
audience: 'https://accounts.google.com/o/oauth2/token',
|
12
|
-
scope: 'https://spreadsheets.google.com/feeds/'
|
13
|
-
)
|
7
|
+
@options = options
|
8
|
+
@options[:scope] ||= 'https://spreadsheets.google.com/feeds/'
|
14
9
|
end
|
15
10
|
|
16
11
|
def call(connection)
|
17
|
-
|
18
|
-
@
|
19
|
-
|
20
|
-
token_credential_uri: @options[:token_credential_uri],
|
21
|
-
audience: @options[:audience],
|
22
|
-
scope: @options[:scope],
|
23
|
-
issuer: @options[:client_email],
|
24
|
-
signing_key: OpenSSL::PKey::RSA.new(@options[:private_key_pem])
|
25
|
-
)
|
26
|
-
c.authorization.fetch_access_token!
|
27
|
-
end
|
28
|
-
if @client.authorization.expired?
|
29
|
-
@client.authorization.refresh!
|
30
|
-
end
|
31
|
-
@client.authorization.access_token
|
12
|
+
@authorizer ||= Google::Auth::ServiceAccountCredentials.make_creds(@options)
|
13
|
+
@authorizer.refresh! if @authorizer.expires_at.nil? || @authorizer.expired?
|
14
|
+
@authorizer.access_token
|
32
15
|
end
|
33
16
|
end
|
34
17
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeresource-google_spreadsheets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chihiro Ito
|
@@ -9,20 +9,20 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-12-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activeresource
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: 4.1.0
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - "
|
25
|
+
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: 4.1.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
@@ -40,19 +40,19 @@ dependencies:
|
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
|
-
name:
|
43
|
+
name: googleauth
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - "
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: 0
|
48
|
+
version: '0'
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- - "
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 0
|
55
|
+
version: '0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: bundler
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -135,8 +135,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
135
|
version: '0'
|
136
136
|
requirements: []
|
137
137
|
rubyforge_project:
|
138
|
-
rubygems_version: 2.
|
138
|
+
rubygems_version: 2.6.14
|
139
139
|
signing_key:
|
140
140
|
specification_version: 4
|
141
141
|
summary: Google Spreadsheets accessor with ActiveResource
|
142
142
|
test_files: []
|
143
|
+
has_rdoc:
|