Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #417 from tomtaylor/master
Added Flickr OAuth provider
- Loading branch information
Showing
6 changed files
with
46 additions
and
94 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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,39 @@ | ||
require 'omniauth/oauth' | ||
require 'multi_json' | ||
|
||
module OmniAuth | ||
module Strategies | ||
|
||
class Flickr < OmniAuth::Strategies::OAuth | ||
def initialize(app, consumer_key=nil, consumer_secret=nil, options={}, &block) | ||
scope = options.delete(:scope) || 'read' | ||
options[:authorize_params] ||= {} | ||
options[:authorize_params][:perms] = scope | ||
|
||
client_options = { | ||
:access_token_path => "/services/oauth/access_token", | ||
:authorize_path => "/services/oauth/authorize", | ||
:request_token_path => "/services/oauth/request_token", | ||
:site => "http://www.flickr.com" | ||
} | ||
super(app, :flickr, consumer_key, consumer_secret, client_options, options, &block) | ||
end | ||
|
||
def auth_hash | ||
OmniAuth::Utils.deep_merge( | ||
super, { | ||
'uid' => @access_token.params["user_nsid"], | ||
'user_info' => user_info | ||
} | ||
) | ||
end | ||
|
||
def user_info | ||
{ | ||
'username' => @access_token.params["username"], | ||
'full_name' => @access_token.params["fullname"] | ||
} | ||
end | ||
end | ||
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,6 @@ | ||
require 'spec_helper' | ||
|
||
describe OmniAuth::Strategies::Flickr do | ||
it_should_behave_like "an oauth strategy" | ||
end | ||
|