Navigation Menu

Skip to content

Commit

Permalink
Adds Bitly strategy.
Browse files Browse the repository at this point in the history
  • Loading branch information
philnash committed Jan 12, 2011
1 parent 91200ff commit aed428d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions oa-oauth/lib/omniauth/oauth.rb
Expand Up @@ -23,5 +23,6 @@ module Strategies
autoload :TypePad, 'omniauth/strategies/type_pad'
autoload :Google, 'omniauth/strategies/google'
autoload :Netflix, 'omniauth/strategies/netflix'
autoload :Bitly, 'omniauth/strategies/bitly'
end
end
29 changes: 29 additions & 0 deletions oa-oauth/lib/omniauth/strategies/bitly.rb
@@ -0,0 +1,29 @@
require 'omniauth/oauth'
require 'multi_json'

module OmniAuth
module Strategies
#
# Authenticate to Bitly utilizing OAuth 2.0 and retrieve
# basic user information.
#
# @example Basic Usage
# use OmniAuth::Strategies::Bitly, 'API Key', 'Secret Key'
class Bitly < OAuth2
# @param [Rack Application] app standard middleware application parameter
# @param [String] api_key the application id as [registered on Bitly](http://bit.ly/a/account)
# @param [String] secret_key the application secret as [registered on Bitly](http://bit.ly/a/account)
def initialize(app, api_key = nil, secret_key = nil, options = {}, &block)
client_options = {
:site => 'https://bit.ly',
:authorize_url => 'https://bit.ly/oauth/authorize',
:access_token_url => 'https://api-ssl.bit.ly/oauth/access_token'
}

super(app, :bitly, api_key, secret_key, client_options, options, &block)
end
end

end

end
5 changes: 5 additions & 0 deletions oa-oauth/spec/omniauth/strategies/bitly_spec.rb
@@ -0,0 +1,5 @@
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')

describe OmniAuth::Strategies::Bitly do
it_should_behave_like "an oauth2 strategy"
end

0 comments on commit aed428d

Please sign in to comment.