fatsecret-omniauth 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +16 -11
- data/Rakefile +8 -0
- data/lib/api/fatsecret_api.rb +23 -0
- data/lib/fatsecret-omniauth/version.rb +1 -1
- data/lib/fatsecret-omniauth.rb +1 -0
- metadata +21 -3
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# FatSecret OmniAuth Gem
|
1
|
+
# FatSecret OmniAuth Gem v0.0.2
|
2
2
|
|
3
3
|
First things first - This is NOT an [OmniAuth] Strategy. This is not meant to be used as a Login
|
4
4
|
method for web apps. This gem leverages OmniAuth's OAuth Strategy to obtain __auth tokens__ and
|
@@ -16,8 +16,10 @@ gem 'fatsecret-omniauth'
|
|
16
16
|
Then run `bundle install`
|
17
17
|
|
18
18
|
___
|
19
|
-
##
|
20
|
-
|
19
|
+
## Authentication
|
20
|
+
This works like any other OmniAuth strategy.
|
21
|
+
Add the following to `config/initializers/omniauth.rb`:
|
22
|
+
|
21
23
|
```ruby
|
22
24
|
Rails.application.config.middleware.use OmniAuth::Builder do
|
23
25
|
provider :fatsecret, 'consumer_key', 'consumer_secret'
|
@@ -32,14 +34,17 @@ __NOTE:__ *OmniAuth strategies use `get '/auth/:provider/callback', to: 'session
|
|
32
34
|
The FatSecret OmniAuth gem requires a custom controller/create method to save the
|
33
35
|
auth tokens in a database for future API calls.*
|
34
36
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
*
|
39
|
-
`request.env['omniauth.auth']
|
40
|
-
|
41
|
-
* __FatSecret
|
42
|
-
`request.env['omniauth.auth']['
|
37
|
+
To authenticate wuth FatSsecret
|
38
|
+
* load `/auth/fatsecret`
|
39
|
+
* You'll be redirected to FatSecret.com to authenticate
|
40
|
+
* If you agree to authenticate, you'll be redirected back `/auth/fatsecret/callback`
|
41
|
+
* The `request.env['omniauth.auth']` hash will contain your FatSecret data.
|
42
|
+
|
43
|
+
* __FatSecret profile data__ is contained in:
|
44
|
+
`request.env['omniauth.auth']['info']` -- see the [FatSecret profile.get page] for more details.
|
45
|
+
|
46
|
+
* __FatSecret auth token and auth secret__ are contained in:
|
47
|
+
`request.env['omniauth.auth']['credentials']`
|
43
48
|
|
44
49
|
[FatSecret profile.get page]: http://platform.fatsecret.com/api/Default.aspx?screen=rapiref&method=profile.get "FatSecret profile.get page"
|
45
50
|
|
data/Rakefile
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Fatsecret
|
2
|
+
class Api < OmniAuth::Strategies::Fatsecret
|
3
|
+
option :client_options, {
|
4
|
+
:scheme => :query_string,
|
5
|
+
:http_method => :get
|
6
|
+
}
|
7
|
+
|
8
|
+
def api_call consumer_key, consumer_secret, params, auth_token=nil, auth_secret=nil
|
9
|
+
request = build_request(consumer_key, consumer_secret, auth_token, auth_secret)
|
10
|
+
request_params = uri(params)
|
11
|
+
request.get "http://platform.fatsecret.com/rest/server.api?#{ request_params }"
|
12
|
+
end
|
13
|
+
|
14
|
+
def uri params
|
15
|
+
normalize = OAuth::Helper.normalize(params)
|
16
|
+
end
|
17
|
+
|
18
|
+
def build_request consumer_key, consumer_secret, auth_token, auth_secret
|
19
|
+
fatsecret = Fatsecret::Api.new :fatsecret, consumer_key, consumer_secret
|
20
|
+
access_token = OAuth::AccessToken.new fatsecret.consumer, auth_token, auth_secret
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/fatsecret-omniauth.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fatsecret-omniauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-08-
|
12
|
+
date: 2013-08-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: omniauth-oauth
|
@@ -59,6 +59,22 @@ dependencies:
|
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rake
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
62
78
|
- !ruby/object:Gem::Dependency
|
63
79
|
name: rack-test
|
64
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -82,6 +98,7 @@ executables: []
|
|
82
98
|
extensions: []
|
83
99
|
extra_rdoc_files: []
|
84
100
|
files:
|
101
|
+
- lib/api/fatsecret_api.rb
|
85
102
|
- lib/fatsecret-omniauth/version.rb
|
86
103
|
- lib/fatsecret-omniauth.rb
|
87
104
|
- lib/omniauth/strategies/fatsecret.rb
|
@@ -90,7 +107,8 @@ files:
|
|
90
107
|
- Rakefile
|
91
108
|
- README.md
|
92
109
|
homepage: https://github.com/scrawlon/fatsecret-omniauth
|
93
|
-
licenses:
|
110
|
+
licenses:
|
111
|
+
- MIT
|
94
112
|
post_install_message:
|
95
113
|
rdoc_options: []
|
96
114
|
require_paths:
|