Skip to content

Commit 082435b

Browse files
committed
initial import
1 parent 013121e commit 082435b

File tree

5 files changed

+131
-3
lines changed

5 files changed

+131
-3
lines changed

README.md

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,52 @@
1-
omniauth-shine
2-
==============
1+
# OmniAuth Shine
2+
3+
This gem contains an oauth2 Shine strategy for OmniAuth.
4+
5+
As of May 2014, the Misfit API is available by request. Contact Misfit for information.
6+
7+
http://misfitwearables.com
8+
9+
10+
## How To Use It
11+
12+
Usage is as per any other OmniAuth 1.0 strategy. So let's say you're using Rails, you need to add the strategy to your `Gemfile` along side omniauth:
13+
14+
```ruby
15+
gem 'omniauth'
16+
gem 'omniauth-shine'
17+
```
18+
19+
Once these are in, you need to add the following to your `config/initializers/omniauth.rb`:
20+
21+
```ruby
22+
Rails.application.config.middleware.use OmniAuth::Builder do
23+
provider :shine, "consumer_key", "consumer_secret"
24+
end
25+
```
26+
27+
You will obviously have to put in your key and secret, which you get when you register your app with Misfit.
28+
29+
Now just follow the README at: https://github.com/intridea/omniauth
30+
31+
32+
## User ID
33+
34+
Some omniauth strategies are able to grab the user ID during the
35+
authenticatino process. This one does not. If you want the user ID then
36+
you will need to make a call to for the profile once you get a valid
37+
token.
38+
39+
40+
## Note on Patches/Pull Requests
41+
42+
- Fork the project.
43+
- Make your feature addition or bug fix.
44+
- Add tests for it. This is important so I don’t break it in a future version unintentionally.
45+
- Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
46+
- Send me a pull request. Bonus points for topic branches.
47+
48+
49+
## License
50+
51+
MIT
352

4-
omniauth hookup for misfit shine oauth

lib/omniauth-shine.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require 'omniauth-shine/version'
2+
require 'omniauth/strategies/shine'

lib/omniauth-shine/version.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module OmniAuth
2+
module Shine
3+
VERSION = "0.0.1"
4+
end
5+
end

lib/omniauth/strategies/shine.rb

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
require 'omniauth-oauth2'
2+
3+
module OmniAuth
4+
module Strategies
5+
class Shine < OmniAuth::Strategies::OAuth2
6+
DEFAULT_SCOPE = 'activity'
7+
8+
option :client_options, {
9+
:site => 'https://api.misfitwearables.com',
10+
:authorize_url => '/auth/dialog/authorize',
11+
:token_url => '/auth/tokens/exchange'
12+
}
13+
14+
# provider does not really ignore state, but am getting
15+
# error when returning via the moves: scheme link.
16+
# option :provider_ignores_state, true
17+
18+
19+
# uid { raw_info['userId'] }
20+
uid { '12345' }
21+
# info do { :firstDate => (raw_info['profile'] || {})['firstDate'] } end
22+
info do { :foo => 'fee' } end
23+
extra do { :raw_info => raw_info } end
24+
25+
def request_phase
26+
options[:authorize_params] = client_params.merge(options[:authorize_params])
27+
super
28+
end
29+
30+
def auth_hash
31+
OmniAuth::Utils.deep_merge(super, client_params.merge({:grant_type => 'authorization_code'}))
32+
end
33+
34+
def raw_info
35+
# @raw_info ||= access_token.get('https://api.misfitwearables.com/move/v1/user/me/profile').parsed
36+
@raw_info
37+
end
38+
39+
private
40+
41+
def client_params
42+
{:client_id => options[:client_id], :redirect_uri => callback_url ,:response_type => "code", :scope => DEFAULT_SCOPE}
43+
end
44+
end
45+
end
46+
end
47+
48+
49+
# REQUEST->
50+
# https://api.misfitwearables.com/auth/dialog/authorize?client_id=2NkGXtz09DBjffJK & redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fauth%2Fshine%2Fcallback & response_type=code & state=3958ee59df5e8376e109109409046be64cad30ecbf4384fe

omniauth-shine.gemspec

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
$:.push File.expand_path("../lib", __FILE__)
2+
require "omniauth-shine/version"
3+
4+
Gem::Specification.new do |s|
5+
s.name = "omniauth-shine"
6+
s.version = Omniauth::Shine::VERSION
7+
s.authors = ["Mathias Kolehmainen"]
8+
s.email = ["[email protected]"]
9+
s.homepage = "https://github.com/socialworkout/omniauth-shine"
10+
s.summary = %q{Misfit Shine strategy for OmniAuth.}
11+
s.description = %q{Misfit Shine strategy for OmniAuth.}
12+
s.license = 'MIT'
13+
14+
s.files = `git ls-files`.split("\n")
15+
# s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16+
# s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17+
s.require_paths = ["lib"]
18+
19+
s.add_runtime_dependency 'omniauth-oauth2', '~> 1.1'
20+
21+
# s.add_development_dependency 'rspec', '~> 2.7'
22+
end
23+

0 commit comments

Comments
 (0)