omniauth-misfit 1.0.0
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.
- checksums.yaml +7 -0
- data/LICENSE +22 -0
- data/README.md +48 -0
- data/lib/omniauth-misfit.rb +2 -0
- data/lib/omniauth-misfit/version.rb +5 -0
- data/lib/omniauth/strategies/misfit.rb +57 -0
- data/omniauth-misfit.gemspec +19 -0
- metadata +64 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a15f378584803dccc013c3fffe346a7901081341
|
4
|
+
data.tar.gz: cab7d3e574038bad010887ebbe8133d40389ecef
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 88d1a424011a7cf0cec0eaf4493713537b5be419b71c2bca0c539c48dfcf636ac64f29afe2b70664d72b031e24a4fdb35ad5846a091ec5f6ff45a43215a9dbb2
|
7
|
+
data.tar.gz: 6f852c5bf63eb678dbe2ddc87562ca74a1bbb7b9af5dc588fdb30949dabe5089f63cc44d4b0f0deda8f8f62390f47adcf3b95568e5b88827c049e43f6a69d77e
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Jeff Judge
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# Omniauth Misfit
|
2
|
+
|
3
|
+
OmniAuth strategy for the [Misfit API](https://build.misfit.com/docs/cloudapi/get_started)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's `Gemfile`:
|
8
|
+
|
9
|
+
gem 'omniauth-misfit'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install omniauth-misfit
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
First, you'll need to register your application with Misfit to obtain a consumer key and secret at [build.misfit.com](https://build.misfit.com/signup).
|
22
|
+
|
23
|
+
Next, add the strategy to your `Gemfile` alongside OmniAuth:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
gem 'omniauth'
|
27
|
+
gem 'omniauth-misfit'
|
28
|
+
```
|
29
|
+
|
30
|
+
Then integrate the strategy into your middleware:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
use OmniAuth::Builder do
|
34
|
+
provider :misfit, ENV['MISFIT_CONSUMER_KEY'], ENV['MISFIT_CONSUMER_SECRET']
|
35
|
+
end
|
36
|
+
```
|
37
|
+
|
38
|
+
In Rails, you'll want to add to the middleware stack:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
42
|
+
provider :misfit, ENV['MISFIT_CONSUMER_KEY'], ENV['MISFIT_CONSUMER_SECRET']
|
43
|
+
end
|
44
|
+
```
|
45
|
+
|
46
|
+
## Copyright
|
47
|
+
|
48
|
+
Copyright (c) 2016 Jeff Judge. See [LICENSE](https://github.com/jjudge/omniauth-misfit/blob/master/LICENSE) for details.
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
class Misfit < OmniAuth::Strategies::OAuth2
|
7
|
+
|
8
|
+
DEFAULT_SCOPE = 'public,birthday,email'
|
9
|
+
|
10
|
+
option :name, 'misfit'
|
11
|
+
|
12
|
+
option :client_options, {
|
13
|
+
:site => 'https://api.misfitwearables.com',
|
14
|
+
:authorize_url => '/auth/dialog/authorize',
|
15
|
+
:token_url => '/auth/tokens/exchange'
|
16
|
+
}
|
17
|
+
|
18
|
+
uid do
|
19
|
+
raw_info['userId']
|
20
|
+
end
|
21
|
+
|
22
|
+
info do
|
23
|
+
{
|
24
|
+
:name => raw_info['name'],
|
25
|
+
:email => raw_info['email'],
|
26
|
+
:gender => raw_info['gender'],
|
27
|
+
:birthday => raw_info['birthday'],
|
28
|
+
:avatar => raw_info['avatar']
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
extra do
|
33
|
+
{
|
34
|
+
:raw_info => raw_info
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
def request_phase
|
39
|
+
options[:authorize_params] = client_params.merge(options[:authorize_params])
|
40
|
+
super
|
41
|
+
end
|
42
|
+
|
43
|
+
def auth_hash
|
44
|
+
OmniAuth::Utils.deep_merge(super, client_params.merge({:grant_type => 'authorization_code'}))
|
45
|
+
end
|
46
|
+
|
47
|
+
def raw_info
|
48
|
+
@raw_info ||= MultiJson.load(access_token.get('/move/resource/v1/user/me/profile').body)
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
def client_params
|
53
|
+
{:client_id => options[:client_id], :redirect_uri => callback_url, :response_type => 'code', :scope => DEFAULT_SCOPE}
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "omniauth-misfit/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "omniauth-misfit"
|
7
|
+
s.version = OmniAuth::Misfit::VERSION
|
8
|
+
s.authors = ["Jeff Judge"]
|
9
|
+
s.email = ["jeff@judge.io"]
|
10
|
+
s.homepage = "http://github.com/jjudge/omniauth-misfit"
|
11
|
+
s.summary = %q{Misfit strategy for OmniAuth}
|
12
|
+
s.description = %q{Misfit strategy for OmniAuth}
|
13
|
+
s.license = 'MIT'
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split($\)
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
|
18
|
+
s.add_runtime_dependency 'omniauth-oauth', '~> 1.0'
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-misfit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jeff Judge
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: omniauth-oauth
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
description: Misfit strategy for OmniAuth
|
28
|
+
email:
|
29
|
+
- jeff@judge.io
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- LICENSE
|
35
|
+
- README.md
|
36
|
+
- lib/omniauth-misfit.rb
|
37
|
+
- lib/omniauth-misfit/version.rb
|
38
|
+
- lib/omniauth/strategies/misfit.rb
|
39
|
+
- omniauth-misfit.gemspec
|
40
|
+
homepage: http://github.com/jjudge/omniauth-misfit
|
41
|
+
licenses:
|
42
|
+
- MIT
|
43
|
+
metadata: {}
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
requirements: []
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 2.4.6
|
61
|
+
signing_key:
|
62
|
+
specification_version: 4
|
63
|
+
summary: Misfit strategy for OmniAuth
|
64
|
+
test_files: []
|