Skip to content

Commit 9c08812

Browse files
committed
Initial commit.
0 parents  commit 9c08812

13 files changed

Lines changed: 229 additions & 0 deletions

File tree

.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
*.gem
2+
*.rbc
3+
.bundle
4+
.config
5+
.yardoc
6+
.DS_Store
7+
Gemfile.lock
8+
InstalledFiles
9+
_yardoc
10+
coverage
11+
doc/
12+
lib/bundler/man
13+
pkg
14+
rdoc
15+
spec/reports
16+
test/tmp
17+
test/version_tmp
18+
tmp

.rspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--color

Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source 'https://rubygems.org'
2+
3+
gemspec

LICENSE.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Copyright (c) 2013 Francois Deschenes
2+
3+
MIT License
4+
5+
Permission is hereby granted, free of charge, to any person obtaining
6+
a copy of this software and associated documentation files (the
7+
"Software"), to deal in the Software without restriction, including
8+
without limitation the rights to use, copy, modify, merge, publish,
9+
distribute, sublicense, and/or sell copies of the Software, and to
10+
permit persons to whom the Software is furnished to do so, subject to
11+
the following conditions:
12+
13+
The above copyright notice and this permission notice shall be
14+
included in all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# OmniAuth Hootsuite
2+
3+
[![Gem Version](https://badge.fury.io/rb/omniauth-hootsuite.png)](http://badge.fury.io/rb/omniauth-hootsuite)
4+
[![Build Status](https://travis-ci.org/hypemarks/omniauth-hootsuite.png?branch=master)](https://travis-ci.org/hypemarks/omniauth-hootsuite)
5+
[![Code Climate](https://codeclimate.com/github/hypemarks/omniauth-hootsuite.png)](https://codeclimate.com/github/hypemarks/omniauth-hootsuite)
6+
[![Dependency Status](https://gemnasium.com/hypemarks/omniauth-hootsuite.png)](https://gemnasium.com/hypemarks/omniauth-hootsuite)
7+
[![Coverage Status](https://coveralls.io/repos/hypemarks/omniauth-hootsuite/badge.png?branch=master)](https://coveralls.io/r/hypemarks/omniauth-hootsuite?branch=master)
8+
9+
This is the OmniAuth strategy for authentication to [Hootsuite](https://hootsuite.com).
10+
11+
## Installation
12+
13+
Add this line to your application's Gemfile:
14+
15+
```ruby
16+
gem 'omniauth-hootsuite'
17+
```
18+
19+
And then, 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 :hootsuite, "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 with Hootsuite](https://developer.hootsuite.com).

Rakefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
require 'bundler/gem_tasks'
2+
require 'rspec/core/rake_task'
3+
4+
RSpec::Core::RakeTask.new
5+
6+
task default: :spec

lib/omniauth/hootsuite.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
require 'omniauth/hootsuite/version'
2+
require 'omniauth/strategies/hootsuite'
3+
4+
module Omniauth
5+
module Hootsuite
6+
end
7+
end

lib/omniauth/hootsuite/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 Hootsuite
3+
VERSION = '1.0.0'
4+
end
5+
end
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
require 'multi_json'
2+
require 'omniauth-oauth2'
3+
4+
module OmniAuth
5+
module Strategies
6+
class Hootsuite < OmniAuth::Strategies::OAuth2
7+
option :client_options, {
8+
site: 'https://platform.hootsuite.com/',
9+
token_url: 'https://platform.hootsuite.com/oauth2/token',
10+
authorize_url: 'https://platform.hootsuite.com/oauth2/auth',
11+
}
12+
13+
option :authorize_params, {
14+
response_type: "code",
15+
scope: "offline"
16+
}
17+
18+
uid { raw_info['id'] }
19+
20+
info do
21+
{
22+
name: raw_info['fullName'],
23+
email: raw_info['email']
24+
}
25+
end
26+
27+
extra do
28+
{ raw_info: raw_info }
29+
end
30+
31+
def raw_info
32+
@raw_info ||= MultiJson.load(access_token.get('https://platform.hootsuite.com/v1/me').body)['data']
33+
end
34+
35+
def callback_phase
36+
request.params['state'] = session['omniauth.state'] unless request.params['state']
37+
super
38+
end
39+
40+
def callback_url
41+
full_host + script_name + callback_path
42+
end
43+
end
44+
end
45+
end
46+
47+
OmniAuth.config.add_camelization 'hootsuite', 'Hootsuite'

omniauth-hootsuite.gemspec

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# -*- encoding: utf-8 -*-
2+
$:.push File.expand_path('../lib', __FILE__)
3+
require 'omniauth/hootsuite/version'
4+
5+
Gem::Specification.new do |s|
6+
s.name = 'omniauth-hootsuite'
7+
s.version = Omniauth::Hootsuite::VERSION
8+
s.authors = ['Francois Deschenes']
9+
s.email = ['fdeschenes@me.com']
10+
s.description = %q{Hootsuite OAuth strategy for OmniAuth}
11+
s.summary = %q{Hootsuite OAuth strategy for OmniAuth}
12+
s.homepage = 'https://github.com/hypemarks/omniauth-hootsuite'
13+
s.license = 'MIT'
14+
15+
s.files = Dir['LICENSE.txt', 'README.md', 'lib/**/*']
16+
s.test_files = Dir['spec/**/*']
17+
s.require_paths = ['lib']
18+
19+
s.add_development_dependency 'bundler', '~> 1.3'
20+
s.add_development_dependency 'rake'
21+
s.add_development_dependency 'rspec'
22+
s.add_development_dependency 'coveralls'
23+
24+
s.add_dependency 'omniauth-oauth2'
25+
s.add_dependency 'multi_json'
26+
end

0 commit comments

Comments
 (0)