glass_sdk 0.0.3 → 0.0.4

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: 047a7dbb44c45aa24e6a7961a3d29cfa7458a144
4
- data.tar.gz: 80dcd5aedff4a908c8c719f0e6780f6782440718
3
+ metadata.gz: 62ec9be8a1248028e47a62a8e6bdd8429bbacebd
4
+ data.tar.gz: df816221b90e0285db9a5b2068f3e286f06d3cfb
5
5
  SHA512:
6
- metadata.gz: 4aad486b8da93c6094f8fe10eb12042c4989b635d23fdca1ff1d1f6f56667f5decdffb4fd33f0c5263b58e376a1ca8a351a301312d0eb898b3cad3ad172b6702
7
- data.tar.gz: 13ab302af88447586e35f96eb4f6f38f0f9b49b7cbebe11078c20b061101742a68dd82aa5266ad100c6529841eb39e6577c2d4e161cf35a7147b3e5f90dc3459
6
+ metadata.gz: 4801556a61b39098a0b93ebfa0bf103ce3436bfe5752e5ba36abad929f840dedf746f1cafb173134369f30aa7702fba8e532941b39d34194ee090df5c75c1e3f
7
+ data.tar.gz: b30ab8d8ae3ea9fb2080a802ce4c2c78274a055f91bfde0c6020de072340d2fb4c551eaf54790257dd348ebd199dfb4bf7cc61c81fea07d681811f2cefb56767
@@ -6,42 +6,43 @@ module GlassSdk
6
6
 
7
7
  # 用户认证基类
8
8
  class OAuth
9
- def initialize
10
- @base_uri = "https://accounts.google.com"
11
- @redirect_uri = GlassSdk.redirect_uri
12
- @access_type = 'offline'
13
- @approval_prompt = 'force'
14
9
 
15
- @client_id = GlassSdk.client_id
16
- @client_secret = GlassSdk.client_secret
17
- @scope = GlassSdk.scope
18
- end
19
-
20
- # 获取用户登录的url
21
- def login_url
22
- params = []
23
- {
24
- response_type: 'code',
25
- client_id: @client_id,
26
- redirect_uri: @redirect_uri,
27
- scope: @scope.join("+"),
28
- access_type: @access_type,
29
- approval_prompt: @approval_prompt
30
- }.each do |key, value|
31
- params << "#{key}=#{value}"
10
+ class << self
11
+ @@base_uri = "https://accounts.google.com"
12
+ @@redirect_uri = GlassSdk.redirect_uri
13
+ @@access_type = 'offline'
14
+ @@approval_prompt = 'force'
15
+
16
+ @@client_id = GlassSdk.client_id
17
+ @@client_secret = GlassSdk.client_secret
18
+ @@scope = GlassSdk.scope
19
+
20
+ # 获取用户登录的url
21
+ def login_url
22
+ params = []
23
+ {
24
+ response_type: 'code',
25
+ client_id: @@client_id,
26
+ redirect_uri: @@redirect_uri,
27
+ scope: @@scope.join("+"),
28
+ access_type: @@access_type,
29
+ approval_prompt: @@approval_prompt
30
+ }.each do |key, value|
31
+ params << "#{key}=#{value}"
32
+ end
33
+ return "#{@@base_uri}/o/oauth2/auth?#{params.join("&")}"
32
34
  end
33
- return "#{@base_uri}/o/oauth2/auth?#{params.join("&")}"
34
- end
35
35
 
36
- # 根据code 换取token
37
- def user_token(code)
38
- RestClient.post "#{@base_uri}/o/oauth2/token", {
39
- code: code,
40
- client_id: @client_id,
41
- client_secret: @client_secret,
42
- redirect_uri: @redirect_uri,
43
- grant_type: 'authorization_code'
44
- }
36
+ # 根据code 换取token
37
+ def user_token(code)
38
+ RestClient.post "#{@@base_uri}/o/oauth2/token", {
39
+ code: code,
40
+ client_id: @@client_id,
41
+ client_secret: @@client_secret,
42
+ redirect_uri: @@redirect_uri,
43
+ grant_type: 'authorization_code'
44
+ }
45
+ end
45
46
  end
46
47
 
47
48
  end
@@ -1,3 +1,3 @@
1
1
  module GlassSdk
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -0,0 +1,15 @@
1
+ GlassSdk.setup do |config|
2
+
3
+ config.client_id = "your client_id"
4
+ config.client_secret = "your client_secret"
5
+
6
+ # your need google api scope
7
+ config.scope = %w{
8
+ https://www.googleapis.com/auth/glass.timeline
9
+ https://www.googleapis.com/auth/userinfo.profile
10
+ }
11
+
12
+ # your need html templaet path
13
+ config.template_path = "#{Rails.root}/lib/views"
14
+ config.redirect_uri = "https://localhost:3000/oauth2callback" #setting your oauth callback
15
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glass_sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - mj
@@ -73,6 +73,7 @@ files:
73
73
  - test/dummy/config/environments/test.rb
74
74
  - test/dummy/config/initializers/backtrace_silencers.rb
75
75
  - test/dummy/config/initializers/filter_parameter_logging.rb
76
+ - test/dummy/config/initializers/glass_sdk.rb
76
77
  - test/dummy/config/initializers/inflections.rb
77
78
  - test/dummy/config/initializers/mime_types.rb
78
79
  - test/dummy/config/initializers/secret_token.rb
@@ -133,6 +134,7 @@ test_files:
133
134
  - test/dummy/config/environments/test.rb
134
135
  - test/dummy/config/initializers/backtrace_silencers.rb
135
136
  - test/dummy/config/initializers/filter_parameter_logging.rb
137
+ - test/dummy/config/initializers/glass_sdk.rb
136
138
  - test/dummy/config/initializers/inflections.rb
137
139
  - test/dummy/config/initializers/mime_types.rb
138
140
  - test/dummy/config/initializers/secret_token.rb