omniauth-yammer 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +20 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/README.md +35 -0
- data/Rakefile +12 -0
- data/lib/omniauth/strategies/yammer.rb +55 -0
- data/lib/omniauth-yammer/version.rb +5 -0
- data/lib/omniauth-yammer.rb +2 -0
- data/omniauth-yammer.gemspec +27 -0
- data/spec/omniauth/strategies/yammer_spec.rb +7 -0
- data/spec/spec_helper.rb +15 -0
- metadata +113 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm ruby-1.9.3-p0@omniauth-yammer-gem --create
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# OmniAuth Yammer
|
2
|
+
|
3
|
+
This gem contains the Yammer strategy for OmniAuth 1.0.
|
4
|
+
|
5
|
+
Supports the OAuth 2.0 server-side flow. Read the Yammer docs for more details: https://developer.yammer.com/api/oauth2.html
|
6
|
+
|
7
|
+
## Installing
|
8
|
+
|
9
|
+
Add to your `Gemfile`:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'omniauth'
|
13
|
+
gem 'omniauth-yammer'
|
14
|
+
```
|
15
|
+
|
16
|
+
or even:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'omniauth'
|
20
|
+
gem 'omniauth-yammer', :git => 'git://github.com/le0pard/omniauth-yammer.git'
|
21
|
+
```
|
22
|
+
|
23
|
+
Then `bundle install`.
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
`OmniAuth::Strategies::Yammer` is simply a Rack middleware. Read the OmniAuth 1.0 docs for detailed instructions: https://github.com/intridea/omniauth.
|
28
|
+
|
29
|
+
Here's a quick example, adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
33
|
+
provider :yammer, ENV['YAMMER_KEY'], ENV['YAMMER_SECRET']
|
34
|
+
end
|
35
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'omniauth/strategies/oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class Yammer < OmniAuth::Strategies::OAuth2
|
6
|
+
option :name, 'yammer'
|
7
|
+
|
8
|
+
option :client_options, {
|
9
|
+
:site => 'https://www.yammer.com',
|
10
|
+
:authorize_url => '/dialog/oauth',
|
11
|
+
:token_url => '/oauth2/access_token.json'
|
12
|
+
}
|
13
|
+
|
14
|
+
uid { raw_info['id'] }
|
15
|
+
|
16
|
+
info do
|
17
|
+
prune!({
|
18
|
+
:nickname => raw_info['name'],
|
19
|
+
:full_name => raw_info['full_name'],
|
20
|
+
:location => raw_info['location'],
|
21
|
+
:image => raw_info['mugshot_url'],
|
22
|
+
:description => raw_info['job_title'],
|
23
|
+
:email => raw_info['contact']['email_addresses'][0]['address'],
|
24
|
+
:urls => {
|
25
|
+
:yammer => raw_info['web_url']
|
26
|
+
}
|
27
|
+
})
|
28
|
+
end
|
29
|
+
|
30
|
+
extra do
|
31
|
+
prune!({:raw_info => raw_info})
|
32
|
+
end
|
33
|
+
|
34
|
+
def build_access_token
|
35
|
+
access_token = super
|
36
|
+
token = eval(access_token.token)['token']
|
37
|
+
@access_token = ::OAuth2::AccessToken.new(client, token, access_token.params)
|
38
|
+
end
|
39
|
+
|
40
|
+
def raw_info
|
41
|
+
@raw_info ||= access_token.get('/api/v1/users/current.json').parsed
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def prune!(hash)
|
47
|
+
hash.delete_if do |_, value|
|
48
|
+
prune!(value) if value.is_a?(Hash)
|
49
|
+
value.nil? || (value.respond_to?(:empty?) && value.empty?)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/omniauth-yammer/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Alexey Vasiliev"]
|
6
|
+
gem.email = ["leopard.not.a@gmail.com"]
|
7
|
+
gem.description = %q{OmniAuth strategy for Yammer}
|
8
|
+
gem.summary = %q{OmniAuth strategy for Yammer}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.rubyforge_project = "omniauth-yammer"
|
12
|
+
|
13
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
14
|
+
gem.files = `git ls-files`.split("\n")
|
15
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
gem.name = "omniauth-yammer"
|
17
|
+
gem.require_paths = ["lib"]
|
18
|
+
gem.version = OmniAuth::Yammer::VERSION
|
19
|
+
|
20
|
+
|
21
|
+
gem.add_runtime_dependency 'omniauth-oauth2', '~> 1.0'
|
22
|
+
|
23
|
+
gem.add_development_dependency 'rspec', '~> 2.7'
|
24
|
+
gem.add_development_dependency 'rack-test'
|
25
|
+
gem.add_development_dependency 'simplecov'
|
26
|
+
gem.add_development_dependency 'webmock'
|
27
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
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-yammer'
|
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
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-yammer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Alexey Vasiliev
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-12-09 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: omniauth-oauth2
|
16
|
+
requirement: &70275882371180 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70275882371180
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &70275882370580 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.7'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70275882370580
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rack-test
|
38
|
+
requirement: &70275882370120 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70275882370120
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: simplecov
|
49
|
+
requirement: &70275882369560 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70275882369560
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: webmock
|
60
|
+
requirement: &70275882369020 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70275882369020
|
69
|
+
description: OmniAuth strategy for Yammer
|
70
|
+
email:
|
71
|
+
- leopard.not.a@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- .rvmrc
|
78
|
+
- Gemfile
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- lib/omniauth-yammer.rb
|
82
|
+
- lib/omniauth-yammer/version.rb
|
83
|
+
- lib/omniauth/strategies/yammer.rb
|
84
|
+
- omniauth-yammer.gemspec
|
85
|
+
- spec/omniauth/strategies/yammer_spec.rb
|
86
|
+
- spec/spec_helper.rb
|
87
|
+
homepage: ''
|
88
|
+
licenses: []
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
101
|
+
requirements:
|
102
|
+
- - ! '>='
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project: omniauth-yammer
|
107
|
+
rubygems_version: 1.8.10
|
108
|
+
signing_key:
|
109
|
+
specification_version: 3
|
110
|
+
summary: OmniAuth strategy for Yammer
|
111
|
+
test_files:
|
112
|
+
- spec/omniauth/strategies/yammer_spec.rb
|
113
|
+
- spec/spec_helper.rb
|