fatsecret-omniauth 0.0.1
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/MIT-LICENSE +20 -0
- data/README.md +50 -0
- data/Rakefile +38 -0
- data/lib/fatsecret-omniauth/version.rb +5 -0
- data/lib/fatsecret-omniauth.rb +2 -0
- data/lib/omniauth/strategies/fatsecret.rb +30 -0
- data/lib/tasks/fatsecret-omniauth_tasks.rake +4 -0
- metadata +116 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Scott McGrath
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# FatSecret OmniAuth Gem
|
2
|
+
|
3
|
+
First things first - This is NOT an [OmniAuth] Strategy. This is not meant to be used as a Login
|
4
|
+
method for web apps. This gem leverages OmniAuth's OAuth Strategy to obtain __auth tokens__ and
|
5
|
+
__auth secrets__ for use with the [FatSecret REST API].
|
6
|
+
|
7
|
+
[OmniAuth]: https://github.com/intridea/omniauth "OmniAuth"
|
8
|
+
[FatSecret REST API]: http://platform.fatsecret.com/api/Default.aspx?screen=rapih "FatSecret REST API"
|
9
|
+
___
|
10
|
+
## Installing
|
11
|
+
|
12
|
+
Add the strategy to your `Gemfile`:
|
13
|
+
```
|
14
|
+
gem 'fatsecret-omniauth'
|
15
|
+
```
|
16
|
+
Then run `bundle install`
|
17
|
+
|
18
|
+
___
|
19
|
+
## Usage
|
20
|
+
Add the following to your middleware in `config/initializers/omniauth.rb`:
|
21
|
+
```ruby
|
22
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
23
|
+
provider :fatsecret, 'consumer_key', 'consumer_secret'
|
24
|
+
end
|
25
|
+
```
|
26
|
+
|
27
|
+
Add your callback route in `config/routes.rb`:
|
28
|
+
```
|
29
|
+
get '/auth/fatsecret/callback', to: 'YOUR_CREATE_METHOD'
|
30
|
+
```
|
31
|
+
__NOTE:__ *OmniAuth strategies use `get '/auth/:provider/callback', to: 'sessions#create'`.
|
32
|
+
The FatSecret OmniAuth gem requires a custom controller/create method to save the
|
33
|
+
auth tokens in a database for future API calls.*
|
34
|
+
|
35
|
+
When your app calls FatSecret and the user authorizes, the `request.env['omniauth.auth']`
|
36
|
+
hash will contain your user data.
|
37
|
+
|
38
|
+
* __FatSecret profile data__ is contained in:
|
39
|
+
`request.env['omniauth.auth']['info']` -- see the [FatSecret profile.get page] for more details.
|
40
|
+
|
41
|
+
* __FatSecret auth token and auth secret__ are contained in:
|
42
|
+
`request.env['omniauth.auth']['credentials']`
|
43
|
+
|
44
|
+
[FatSecret profile.get page]: http://platform.fatsecret.com/api/Default.aspx?screen=rapiref&method=profile.get "FatSecret profile.get page"
|
45
|
+
|
46
|
+
---
|
47
|
+
Copyright (c) 2013 Scott McGrath. See [LICENSE] for details.
|
48
|
+
|
49
|
+
[LICENSE]: https://github.com/scrawlon/omniauth-fatsecret/blob/master/MIT-LICENSE "LICENSE"
|
50
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'OmniauthFatsecret'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
Bundler::GemHelper.install_tasks
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
|
30
|
+
Rake::TestTask.new(:test) do |t|
|
31
|
+
t.libs << 'lib'
|
32
|
+
t.libs << 'test'
|
33
|
+
t.pattern = 'test/**/*_test.rb'
|
34
|
+
t.verbose = false
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
task :default => :test
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'omniauth-oauth'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
class Fatsecret < OmniAuth::Strategies::OAuth
|
7
|
+
option :client_options, {
|
8
|
+
:site => 'http://www.fatsecret.com',
|
9
|
+
:scheme => :query_string,
|
10
|
+
:http_method => :get
|
11
|
+
}
|
12
|
+
|
13
|
+
info do
|
14
|
+
{
|
15
|
+
goal_weight_kg: raw_info['goal_weight_kg'],
|
16
|
+
height_cm: raw_info['height_cm'],
|
17
|
+
height_measure: raw_info['height_measure'],
|
18
|
+
last_weight_comment: raw_info['last_weight_comment'],
|
19
|
+
last_weight_date_int: raw_info['last_weight_date_int'],
|
20
|
+
last_weight_kg: raw_info['last_weight_kg'],
|
21
|
+
weight_measure: raw_info['weight_measure']
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
def raw_info
|
26
|
+
@raw_info ||= MultiJson.decode(access_token.get('http://platform.fatsecret.com/rest/server.api?method=profile.get&format=json').body)['profile']
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fatsecret-omniauth
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Scott McGrath
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-08-12 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: omniauth-oauth
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: multi_json
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rack-test
|
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'
|
78
|
+
description: FatSecret Authentication Gem
|
79
|
+
email:
|
80
|
+
- acid64k@yahoo.com
|
81
|
+
executables: []
|
82
|
+
extensions: []
|
83
|
+
extra_rdoc_files: []
|
84
|
+
files:
|
85
|
+
- lib/fatsecret-omniauth/version.rb
|
86
|
+
- lib/fatsecret-omniauth.rb
|
87
|
+
- lib/omniauth/strategies/fatsecret.rb
|
88
|
+
- lib/tasks/fatsecret-omniauth_tasks.rake
|
89
|
+
- MIT-LICENSE
|
90
|
+
- Rakefile
|
91
|
+
- README.md
|
92
|
+
homepage: https://github.com/scrawlon/fatsecret-omniauth
|
93
|
+
licenses: []
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
100
|
+
requirements:
|
101
|
+
- - ! '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
requirements: []
|
111
|
+
rubyforge_project:
|
112
|
+
rubygems_version: 1.8.24
|
113
|
+
signing_key:
|
114
|
+
specification_version: 3
|
115
|
+
summary: FatSecret Authentication Gem
|
116
|
+
test_files: []
|