omniauth-odnoklassniki 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in omniauth-odnoklassniki.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # OmniAuth Odnoklassniki.ru
2
+
3
+ This is the unofficial OmniAuth strategy for authenticating to Odnoklassniki.ru via OAuth.
4
+ To use it, you'll need to sign up for an [OAuth2](http://dev.odnoklassniki.ru/wiki/display/ok/The+OAuth+2.0+Protocol) Application ID and Keys
5
+ on the [Odnoklassniki Developers Page](http://dev.odnoklassniki.ru/wiki/pages/viewpage.action?pageId=13992188).
6
+
7
+ ## Basic Usage
8
+
9
+ use OmniAuth::Builder do
10
+ provider :odnoklassniki, ENV['APP_ID'], ENV['APP_SECRET_KEY'], :public_key => ENV['APP_PUBLIC_KEY']
11
+ end
12
+
13
+ ## License
14
+
15
+ Copyright (c) 2011 Alexander Logvinov.
16
+
17
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,2 @@
1
+ require 'omniauth-odnoklassniki/version'
2
+ require 'omniauth/strategies/odnoklassniki'
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Odnoklassniki
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,78 @@
1
+ require 'omniauth/strategies/oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+
6
+ class Odnoklassniki < OmniAuth::Strategies::OAuth2
7
+ option :name, 'odnoklassniki'
8
+
9
+ option :client_options, {
10
+ :site => 'http://www.odnoklassniki.ru/',
11
+ :token_url => 'http://api.odnoklassniki.ru/oauth/token.do',
12
+ :authorize_url => '/oauth/authorize'
13
+ }
14
+
15
+ option :access_token_options, {
16
+ :mode => :query,
17
+ :param_name => 'access_token'
18
+ }
19
+
20
+ uid do
21
+ raw_info['uid']
22
+ end
23
+
24
+ info do
25
+ {
26
+ :name => raw_info['name'],
27
+ :first_name => raw_info['first_name'],
28
+ :last_name => raw_info['last_name'],
29
+ :image => raw_info['pic_1'],
30
+ :urls => {
31
+ 'Odnoklassniki' => "http://www.odnoklassniki.ru/profile/#{uid}",
32
+ }
33
+ }
34
+ end
35
+
36
+ extra do
37
+ { :raw_info => raw_info }
38
+ end
39
+
40
+ def callback_url
41
+ if options.authorize_options.respond_to? :callback_url
42
+ options.authorize_options.callback_url
43
+ else
44
+ super
45
+ end
46
+ end
47
+
48
+ def build_access_token
49
+ super.tap do |token|
50
+ token.options.merge!(access_token_options)
51
+ end
52
+ end
53
+
54
+ def access_token_options
55
+ options.access_token_options.inject({}) { |h,(k,v)| h[k.to_sym] = v; h }
56
+ end
57
+
58
+ private
59
+
60
+ def calculate_signature(params)
61
+ str = params.sort.collect { |c| "#{c[0]}=#{c[1]}" }.join('')
62
+ Digest::MD5.hexdigest(str + Digest::MD5.hexdigest(access_token.token + options.client_secret))
63
+ end
64
+
65
+ def raw_info
66
+ @raw_info ||= begin
67
+ params = {
68
+ 'method' => 'users.getCurrentUser',
69
+ 'application_key' => options.public_key
70
+ }
71
+ params[:sig] = calculate_signature(params)
72
+ access_token.get('http://api.odnoklassniki.ru/fb.do', :params => params).parsed
73
+ end
74
+ end
75
+
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "omniauth-odnoklassniki/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "omniauth-odnoklassniki"
7
+ s.version = Omniauth::Odnoklassniki::VERSION
8
+ s.authors = ["Alexander Logvinov"]
9
+ s.email = ["avl@logvinov.com"]
10
+ s.homepage = "https://github.com/incubus/omniauth-odnoklassniki"
11
+ s.summary = %q{OmniAuth strategy for Odnoklassniki.ru}
12
+ s.description = %q{OmniAuth strategy for Odnoklassniki.ru}
13
+
14
+ s.rubyforge_project = "omniauth-odnoklassniki"
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_runtime_dependency "omniauth", "~> 1.0"
22
+ s.add_runtime_dependency "omniauth-oauth2", "~> 1.0"
23
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-odnoklassniki
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Alexander Logvinov
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-11-27 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth
16
+ requirement: &70350990646720 !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: *70350990646720
25
+ - !ruby/object:Gem::Dependency
26
+ name: omniauth-oauth2
27
+ requirement: &70350990645180 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '1.0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70350990645180
36
+ description: OmniAuth strategy for Odnoklassniki.ru
37
+ email:
38
+ - avl@logvinov.com
39
+ executables: []
40
+ extensions: []
41
+ extra_rdoc_files: []
42
+ files:
43
+ - .gitignore
44
+ - Gemfile
45
+ - README.md
46
+ - Rakefile
47
+ - lib/omniauth-odnoklassniki.rb
48
+ - lib/omniauth-odnoklassniki/version.rb
49
+ - lib/omniauth/strategies/odnoklassniki.rb
50
+ - omniauth-odnoklassniki.gemspec
51
+ homepage: https://github.com/incubus/omniauth-odnoklassniki
52
+ licenses: []
53
+ post_install_message:
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubyforge_project: omniauth-odnoklassniki
71
+ rubygems_version: 1.8.10
72
+ signing_key:
73
+ specification_version: 3
74
+ summary: OmniAuth strategy for Odnoklassniki.ru
75
+ test_files: []
76
+ has_rdoc: