forked from beeminder/omniauth-shine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
131 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,52 @@ | ||
omniauth-shine | ||
============== | ||
# OmniAuth Shine | ||
|
||
This gem contains an oauth2 Shine strategy for OmniAuth. | ||
|
||
As of May 2014, the Misfit API is available by request. Contact Misfit for information. | ||
|
||
http://misfitwearables.com | ||
|
||
|
||
## How To Use It | ||
|
||
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: | ||
|
||
```ruby | ||
gem 'omniauth' | ||
gem 'omniauth-shine' | ||
``` | ||
|
||
Once these are in, you need to add the following to your `config/initializers/omniauth.rb`: | ||
|
||
```ruby | ||
Rails.application.config.middleware.use OmniAuth::Builder do | ||
provider :shine, "consumer_key", "consumer_secret" | ||
end | ||
``` | ||
|
||
You will obviously have to put in your key and secret, which you get when you register your app with Misfit. | ||
|
||
Now just follow the README at: https://github.com/intridea/omniauth | ||
|
||
|
||
## User ID | ||
|
||
Some omniauth strategies are able to grab the user ID during the | ||
authenticatino process. This one does not. If you want the user ID then | ||
you will need to make a call to for the profile once you get a valid | ||
token. | ||
|
||
|
||
## Note on Patches/Pull Requests | ||
|
||
- Fork the project. | ||
- Make your feature addition or bug fix. | ||
- Add tests for it. This is important so I don’t break it in a future version unintentionally. | ||
- 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) | ||
- Send me a pull request. Bonus points for topic branches. | ||
|
||
|
||
## License | ||
|
||
MIT | ||
|
||
omniauth hookup for misfit shine oauth |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
require 'omniauth-shine/version' | ||
require 'omniauth/strategies/shine' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module OmniAuth | ||
module Shine | ||
VERSION = "0.0.1" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
require 'omniauth-oauth2' | ||
|
||
module OmniAuth | ||
module Strategies | ||
class Shine < OmniAuth::Strategies::OAuth2 | ||
DEFAULT_SCOPE = 'activity' | ||
|
||
option :client_options, { | ||
:site => 'https://api.misfitwearables.com', | ||
:authorize_url => '/auth/dialog/authorize', | ||
:token_url => '/auth/tokens/exchange' | ||
} | ||
|
||
# provider does not really ignore state, but am getting | ||
# error when returning via the moves: scheme link. | ||
# option :provider_ignores_state, true | ||
|
||
|
||
# uid { raw_info['userId'] } | ||
uid { '12345' } | ||
# info do { :firstDate => (raw_info['profile'] || {})['firstDate'] } end | ||
info do { :foo => 'fee' } end | ||
extra do { :raw_info => raw_info } end | ||
|
||
def request_phase | ||
options[:authorize_params] = client_params.merge(options[:authorize_params]) | ||
super | ||
end | ||
|
||
def auth_hash | ||
OmniAuth::Utils.deep_merge(super, client_params.merge({:grant_type => 'authorization_code'})) | ||
end | ||
|
||
def raw_info | ||
# @raw_info ||= access_token.get('https://api.misfitwearables.com/move/v1/user/me/profile').parsed | ||
@raw_info | ||
end | ||
|
||
private | ||
|
||
def client_params | ||
{:client_id => options[:client_id], :redirect_uri => callback_url ,:response_type => "code", :scope => DEFAULT_SCOPE} | ||
end | ||
end | ||
end | ||
end | ||
|
||
|
||
# REQUEST-> | ||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
$:.push File.expand_path("../lib", __FILE__) | ||
require "omniauth-shine/version" | ||
|
||
Gem::Specification.new do |s| | ||
s.name = "omniauth-shine" | ||
s.version = Omniauth::Shine::VERSION | ||
s.authors = ["Mathias Kolehmainen"] | ||
s.email = ["[email protected]"] | ||
s.homepage = "https://github.com/socialworkout/omniauth-shine" | ||
s.summary = %q{Misfit Shine strategy for OmniAuth.} | ||
s.description = %q{Misfit Shine strategy for OmniAuth.} | ||
s.license = 'MIT' | ||
|
||
s.files = `git ls-files`.split("\n") | ||
# s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") | ||
# s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } | ||
s.require_paths = ["lib"] | ||
|
||
s.add_runtime_dependency 'omniauth-oauth2', '~> 1.1' | ||
|
||
# s.add_development_dependency 'rspec', '~> 2.7' | ||
end | ||
|