simpleapikeyengine-facebook 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: be6043e1803424e5cb547bc3d629625c87257862
4
+ data.tar.gz: 22bc5a1a6c0d37246a5ef9d428ae10ff7fc9ef04
5
+ SHA512:
6
+ metadata.gz: 5da37cb8177a3b0a02c12be02febc8d1693677243f57f59a43f85ac6b1bf76c3ea07c34028e6801a5b6272084c02db4bc1aa6d9a4828c1338ad701ad3f8670fd
7
+ data.tar.gz: 3c8e34c556b6b40d6328841b3b9cb7f797afa033c8ff3febae31aaead26e8b2e972a6e117eab94a557e09b1321f0e75219d0537af3eb0ba2164a9f71605375c5
@@ -0,0 +1,20 @@
1
+ Copyright 2014 YOURNAME
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.
@@ -0,0 +1,4 @@
1
+ simpleapikeyengine-facebook
2
+ ==============================
3
+
4
+ Facebook Provider for simpleapikeyengine gem.
@@ -0,0 +1,8 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ Bundler::GemHelper.install_tasks
8
+
@@ -0,0 +1,5 @@
1
+ require 'simpleapikeyengine'
2
+ require 'simpleapikeyengine/providers/facebook_provider'
3
+
4
+ module SimpleApiKeyEngineFacebook
5
+ end
@@ -0,0 +1,3 @@
1
+ module SimpleApiKeyEngineFacebook
2
+ VERSION = "0.0.3"
3
+ end
@@ -0,0 +1,48 @@
1
+ require 'simpleapikeyengine/providers/abstract_provider'
2
+ require 'koala'
3
+
4
+ module SimpleApiKeyEngine::Providers
5
+ class FacebookProvider < AbstractProvider
6
+ priority 5
7
+ def self.acceptable?(auth_hash)
8
+ auth_hash[:provider] == 'facebook'
9
+ end
10
+
11
+ def client
12
+ @oauth ||= Koala::Facebook::OAuth.new(SimpleApiKeyEngine.configuration.facebook_app_id,
13
+ SimpleApiKeyEngine.configuration.facebook_app_secret)
14
+ end
15
+
16
+ def get_auth_hash!
17
+ res = client.parse_signed_request(@params[:signed_request])
18
+ short_token = client.get_access_token(res['code'])
19
+ graph = Koala::Facebook::API.new(short_token)
20
+ user_info = graph.get_object('me')
21
+ new_token = client.exchange_access_token_info(short_token)
22
+
23
+ if new_token['expires'].to_i > 0
24
+ expires_at = (Time.now.to_i + new_token['expires'].to_i).to_i
25
+ expires = true
26
+ else
27
+ expires_at = nil
28
+ expires = false
29
+ end
30
+ {
31
+ provider: @params[:provider],
32
+ uid: user_info['id'],
33
+ credentials: {
34
+ token: new_token['access_token'],
35
+ expires_at: expires_at,
36
+ expires: expires
37
+ },
38
+ info: {
39
+ email: user_info['email'],
40
+ name: user_info['name']
41
+ },
42
+ extra: {
43
+ raw_info: user_info.to_h
44
+ }
45
+ }
46
+ end
47
+ end
48
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simpleapikeyengine-facebook
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Yuichi Takeuchi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: koala
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: oauth2
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: simpleapikeyengine
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.0.3
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.0.3
69
+ - !ruby/object:Gem::Dependency
70
+ name: sqlite3
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: "(Description for simpleapikeyengine-facebook)"
98
+ email:
99
+ - uzuki05@takeyu-web.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - MIT-LICENSE
105
+ - README.md
106
+ - Rakefile
107
+ - lib/simpleapikeyengine-facebook.rb
108
+ - lib/simpleapikeyengine-facebook/version.rb
109
+ - lib/simpleapikeyengine/providers/facebook_provider.rb
110
+ homepage: https://github.com/takeyuweb/simpleapikeyengine
111
+ licenses:
112
+ - MIT
113
+ metadata: {}
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubyforge_project:
130
+ rubygems_version: 2.2.2
131
+ signing_key:
132
+ specification_version: 4
133
+ summary: Facebook Provider for simple_api_key_engine gem.
134
+ test_files: []