omniauth-bitly 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +39 -0
- data/README.md +66 -0
- data/Rakefile +8 -0
- data/lib/omniauth/strategies/bitly.rb +48 -0
- data/lib/omniauth-bitly/version.rb +5 -0
- data/lib/omniauth-bitly.rb +2 -0
- data/omniauth-bitly.gemspec +27 -0
- data/spec/omniauth/strategies/bitly_spec.rb +21 -0
- data/spec/spec_helper.rb +16 -0
- metadata +164 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
omniauth-bitly (0.0.4)
|
5
|
+
multi_json (~> 1.3)
|
6
|
+
omniauth-oauth2 (~> 1.1.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
faraday (0.8.4)
|
12
|
+
multipart-post (~> 1.1)
|
13
|
+
hashie (1.2.0)
|
14
|
+
httpauth (0.1)
|
15
|
+
jwt (0.1.5)
|
16
|
+
multi_json (>= 1.0)
|
17
|
+
multi_json (1.3.6)
|
18
|
+
multipart-post (1.1.5)
|
19
|
+
oauth2 (0.8.0)
|
20
|
+
faraday (~> 0.8)
|
21
|
+
httpauth (~> 0.1)
|
22
|
+
jwt (~> 0.1.4)
|
23
|
+
multi_json (~> 1.0)
|
24
|
+
rack (~> 1.2)
|
25
|
+
omniauth (1.1.1)
|
26
|
+
hashie (~> 1.2)
|
27
|
+
rack
|
28
|
+
omniauth-oauth2 (1.1.0)
|
29
|
+
oauth2 (~> 0.8.0)
|
30
|
+
omniauth (~> 1.0)
|
31
|
+
rack (1.4.1)
|
32
|
+
rake (0.9.2.2)
|
33
|
+
|
34
|
+
PLATFORMS
|
35
|
+
ruby
|
36
|
+
|
37
|
+
DEPENDENCIES
|
38
|
+
omniauth-bitly!
|
39
|
+
rake
|
data/README.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# OmniAuth Bit.ly
|
2
|
+
|
3
|
+
This gem contains the Bit.ly strategy for OmniAuth.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'omniauth-bitly', :git => 'https://github.com/michaeldelorenzo/omniauth-bitly.git'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
```sh
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
### Rails
|
23
|
+
|
24
|
+
If you're using Rails, you need to add the strategy to your `Gemfile`:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
gem 'omniauth-bitly', :git => 'https://github.com/michaeldelorenzo/omniauth-bitly.git'
|
28
|
+
```
|
29
|
+
|
30
|
+
Once you've added the gem to your project, you need to add the following to your `config/initializers/omniauth.rb`:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
34
|
+
provider :bitly, "client_id", "client_secret"
|
35
|
+
end
|
36
|
+
```
|
37
|
+
|
38
|
+
Enter your `client_id` and `client_secret`, which you receive when you register your application with Bit.ly.
|
39
|
+
|
40
|
+
Now just follow the README at: https://github.com/intridea/omniauth
|
41
|
+
|
42
|
+
### Sinatra
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
require 'omniauth'
|
46
|
+
require 'omniauth-bitly'
|
47
|
+
|
48
|
+
use Rack::Session::Cookie
|
49
|
+
use OmniAuth::Builder do
|
50
|
+
provider :bitly, "client_id", "client_secret"
|
51
|
+
end
|
52
|
+
|
53
|
+
get '/auth/:provider/callback' do
|
54
|
+
# Do something with auth_hash
|
55
|
+
redirect to('/')
|
56
|
+
end
|
57
|
+
|
58
|
+
def auth_hash
|
59
|
+
request.env['omniauth.auth']
|
60
|
+
end
|
61
|
+
```
|
62
|
+
## NOTES
|
63
|
+
|
64
|
+
This is actually a fork of judearasu's `omniauth-bitly` strategy, but Github wouldn't let me fork it - kept
|
65
|
+
giving me a 404 Page Not Found. Credit goes to him and elrosa for their work. I only added the hack to
|
66
|
+
add the `state` parameter that, as of this writing, Bitly does not support.
|
data/Rakefile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
class Bitly < OmniAuth::Strategies::OAuth2
|
7
|
+
option :name, "bitly"
|
8
|
+
option :client_options,{:site => 'https://api-ssl.bitly.com/',
|
9
|
+
:authorize_url => 'https://bitly.com/oauth/authorize',
|
10
|
+
:token_url => 'https://api-ssl.bitly.com/oauth/access_token'}
|
11
|
+
|
12
|
+
option :token_params, {
|
13
|
+
:parse => :query
|
14
|
+
}
|
15
|
+
|
16
|
+
uid{ access_token.params['login'] }
|
17
|
+
|
18
|
+
|
19
|
+
info do
|
20
|
+
{
|
21
|
+
'login' => access_token.params['login'],
|
22
|
+
'api_key' => access_token.params['apiKey'],
|
23
|
+
'display_name' => raw_info['display_name'],
|
24
|
+
'full_name' => raw_info['full_name'],
|
25
|
+
'profile_image' => raw_info['profile_image'],
|
26
|
+
'profile_url'=>raw_info['profile_url']
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
extra do
|
31
|
+
{:raw_info => raw_info}
|
32
|
+
end
|
33
|
+
|
34
|
+
def raw_info
|
35
|
+
# HACK HACK HACK
|
36
|
+
access_token.options[:mode] = :query
|
37
|
+
access_token.options[:param_name] = :access_token
|
38
|
+
@raw_info ||= MultiJson.decode(access_token.get('/v3/user/info').body)
|
39
|
+
end
|
40
|
+
|
41
|
+
def callback_phase
|
42
|
+
request.params["state"] = session["omniauth.state"] unless request.params["state"]
|
43
|
+
super
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
OmniAuth.config.add_camelization 'bitly', 'Bitly'
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "omniauth-bitly/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "omniauth-bitly"
|
7
|
+
s.version = OmniAuth::Bitly::VERSION
|
8
|
+
s.authors = ["Michael De Lorenzo"]
|
9
|
+
s.email = ["michael@delorenzodesign.com"]
|
10
|
+
s.homepage = "https://github.com/michaeldelorenzo/omniauth-bitly"
|
11
|
+
s.summary = %q{OmniAuth strategy for Bitly.}
|
12
|
+
s.description = %q{OmniAuth strategy for Bitly.}
|
13
|
+
|
14
|
+
s.rubyforge_project = "omniauth-bitly"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_dependency 'multi_json', '~> 1.3'
|
22
|
+
s.add_runtime_dependency 'omniauth-oauth2', '~> 1.1.0'
|
23
|
+
s.add_development_dependency 'rspec', '~> 2.7'
|
24
|
+
s.add_development_dependency 'rack-test'
|
25
|
+
s.add_development_dependency 'simplecov'
|
26
|
+
s.add_development_dependency 'webmock'
|
27
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OmniAuth::Strategies::Bitly do
|
4
|
+
subject do
|
5
|
+
OmniAuth::Strategies::Bitly.new({})
|
6
|
+
end
|
7
|
+
|
8
|
+
context "client options" do
|
9
|
+
it 'should have correct name' do
|
10
|
+
subject.options.name.should eq("bitly")
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should have correct site' do
|
14
|
+
subject.options.client_options.site.should eq('https://api-ssl.bitly.com/')
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should have correct authorize url' do
|
18
|
+
subject.options.client_options.authorize_path.should eq('/oauth/authorize')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
$:.unshift File.expand_path('..', __FILE__)
|
2
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
require 'simplecov'
|
4
|
+
SimpleCov.start
|
5
|
+
require 'rspec'
|
6
|
+
require 'rack/test'
|
7
|
+
require 'webmock/rspec'
|
8
|
+
require 'omniauth'
|
9
|
+
require 'omniauth-bitly'
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.include WebMock::API
|
13
|
+
config.include Rack::Test::Methods
|
14
|
+
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
|
15
|
+
end
|
16
|
+
|
metadata
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-bitly
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 19
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 6
|
10
|
+
version: 0.0.6
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Michael De Lorenzo
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-09-11 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: multi_json
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 9
|
29
|
+
segments:
|
30
|
+
- 1
|
31
|
+
- 3
|
32
|
+
version: "1.3"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: omniauth-oauth2
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 19
|
44
|
+
segments:
|
45
|
+
- 1
|
46
|
+
- 1
|
47
|
+
- 0
|
48
|
+
version: 1.1.0
|
49
|
+
type: :runtime
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: rspec
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ~>
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 13
|
60
|
+
segments:
|
61
|
+
- 2
|
62
|
+
- 7
|
63
|
+
version: "2.7"
|
64
|
+
type: :development
|
65
|
+
version_requirements: *id003
|
66
|
+
- !ruby/object:Gem::Dependency
|
67
|
+
name: rack-test
|
68
|
+
prerelease: false
|
69
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
hash: 3
|
75
|
+
segments:
|
76
|
+
- 0
|
77
|
+
version: "0"
|
78
|
+
type: :development
|
79
|
+
version_requirements: *id004
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: simplecov
|
82
|
+
prerelease: false
|
83
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
hash: 3
|
89
|
+
segments:
|
90
|
+
- 0
|
91
|
+
version: "0"
|
92
|
+
type: :development
|
93
|
+
version_requirements: *id005
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: webmock
|
96
|
+
prerelease: false
|
97
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
hash: 3
|
103
|
+
segments:
|
104
|
+
- 0
|
105
|
+
version: "0"
|
106
|
+
type: :development
|
107
|
+
version_requirements: *id006
|
108
|
+
description: OmniAuth strategy for Bitly.
|
109
|
+
email:
|
110
|
+
- michael@delorenzodesign.com
|
111
|
+
executables: []
|
112
|
+
|
113
|
+
extensions: []
|
114
|
+
|
115
|
+
extra_rdoc_files: []
|
116
|
+
|
117
|
+
files:
|
118
|
+
- .gitignore
|
119
|
+
- Gemfile
|
120
|
+
- Gemfile.lock
|
121
|
+
- README.md
|
122
|
+
- Rakefile
|
123
|
+
- lib/omniauth-bitly.rb
|
124
|
+
- lib/omniauth-bitly/version.rb
|
125
|
+
- lib/omniauth/strategies/bitly.rb
|
126
|
+
- omniauth-bitly.gemspec
|
127
|
+
- spec/omniauth/strategies/bitly_spec.rb
|
128
|
+
- spec/spec_helper.rb
|
129
|
+
homepage: https://github.com/michaeldelorenzo/omniauth-bitly
|
130
|
+
licenses: []
|
131
|
+
|
132
|
+
post_install_message:
|
133
|
+
rdoc_options: []
|
134
|
+
|
135
|
+
require_paths:
|
136
|
+
- lib
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
none: false
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
hash: 3
|
143
|
+
segments:
|
144
|
+
- 0
|
145
|
+
version: "0"
|
146
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
|
+
none: false
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
hash: 3
|
152
|
+
segments:
|
153
|
+
- 0
|
154
|
+
version: "0"
|
155
|
+
requirements: []
|
156
|
+
|
157
|
+
rubyforge_project: omniauth-bitly
|
158
|
+
rubygems_version: 1.8.13
|
159
|
+
signing_key:
|
160
|
+
specification_version: 3
|
161
|
+
summary: OmniAuth strategy for Bitly.
|
162
|
+
test_files:
|
163
|
+
- spec/omniauth/strategies/bitly_spec.rb
|
164
|
+
- spec/spec_helper.rb
|