omniauth-vkontakte 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # OmniAuth VKontakte
2
+
3
+ This is the unofficial VKontakte strategy for authenticating to VKontakte. To
4
+ use it, you'll need to sign up for an OAuth2 Application ID and Secret
5
+ on the [Vkontakte Developers Page](http://vk.com/developers.php).
6
+
7
+ ## Basic Usage
8
+
9
+ use OmniAuth::Builder do
10
+ provider :vkontakte, ENV['API_KEY'], ENV['API_SECRET']
11
+ end
12
+
13
+ ## License
14
+
15
+ Copyright (c) 2011 Anton Maminov.
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,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,27 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+
4
+ Bundler.setup :default, :development, :example
5
+ require 'sinatra'
6
+ require 'omniauth'
7
+ require 'omniauth-vkontakte'
8
+
9
+ use Rack::Session::Cookie
10
+
11
+ use OmniAuth::Builder do
12
+ #provider :vkontakte, ENV['VKONTAKTE_KEY'], ENV['VKONTAKTE_SECRET']
13
+ provider :vkontakte, '1915108', 'BsCEIfRxoDFZU8vZJ65v'
14
+ end
15
+
16
+ get '/' do
17
+ <<-HTML
18
+ <ul>
19
+ <li><a href='/auth/vkontakte'>Sign in with VKontakte</a></li>
20
+ </ul>
21
+ HTML
22
+ end
23
+
24
+ get '/auth/:provider/callback' do
25
+ content_type 'text/plain'
26
+ request.env['omniauth.auth'].info.to_hash.inspect
27
+ end
@@ -0,0 +1,10 @@
1
+ require "omniauth-vkontakte/version"
2
+ require "omniauth"
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ autoload :Vkontakte, 'omniauth/strategies/vkontakte'
7
+ end
8
+ end
9
+
10
+ OmniAuth.config.add_camelization 'vkontakte', 'Vkontakte'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Vkontakte
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,46 @@
1
+ require 'omniauth/strategies/oauth2'
2
+ require 'multi_json'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ # Authenticate to Vkontakte utilizing OAuth 2.0 and retrieve
7
+ # basic user information.
8
+ # documentation available here:
9
+ # http://vkontakte.ru/developers.php?o=-17680044&p=Authorization&s=0
10
+ #
11
+ # @example Basic Usage
12
+ # use OmniAuth::Strategies::Vkontakte, 'API Key', 'Secret Key'
13
+ class Vkontakte < OmniAuth::Strategies::OAuth2
14
+ option :name, 'vkontakte'
15
+
16
+ option :client_options, {
17
+ :site => 'https://api.vk.com/',
18
+ :token_url => '/oauth/token',
19
+ :authorize_url => '/oauth/authorize'
20
+ }
21
+
22
+ option :access_token_options, {
23
+ :param_name => 'access_token',
24
+ }
25
+
26
+ uid { access_token.params['user_id'] }
27
+
28
+ info do
29
+ {
30
+ :first_name => raw_info['first_name'],
31
+ :last_name => raw_info['last_name']
32
+ }
33
+ end
34
+
35
+ extra do
36
+ {'raw_info' => raw_info}
37
+ end
38
+
39
+ def raw_info
40
+ # http://vkontakte.ru/developers.php?o=-17680044&p=Description+of+Fields+of+the+fields+Parameter
41
+ fields = ['uid', 'first_name', 'last_name', 'nickname', 'domain', 'sex', 'bdate', 'city', 'country', 'timezone', 'photo', 'photo_big']
42
+ access_token.get('/method/getProfiles', :params => {:uid => uid, :fields => fields.join(',')}).parsed["response"].first
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/omniauth-vkontakte/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.add_dependency 'omniauth', '~> 1.0'
6
+ gem.add_dependency 'omniauth-oauth2', '~> 1.0'
7
+ gem.add_dependency 'multi_json'
8
+
9
+ gem.authors = ["Anton Maminov"]
10
+ gem.email = ["anton.linux@gmail.com"]
11
+ gem.description = %q{Unofficial VKontakte strategy for OmniAuth 1.0}
12
+ gem.summary = %q{Unofficial VKontakte strategy for OmniAuth 1.0}
13
+ gem.homepage = "https://github.com/mamantoha/omniauth-vkontakte"
14
+
15
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
16
+ gem.files = `git ls-files`.split("\n")
17
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ gem.name = "omniauth-vkontakte"
19
+ gem.require_paths = ["lib"]
20
+ gem.version = OmniAuth::Vkontakte::VERSION
21
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-vkontakte
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Anton Maminov
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-11-05 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth
16
+ requirement: &73123550 !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: *73123550
25
+ - !ruby/object:Gem::Dependency
26
+ name: omniauth-oauth2
27
+ requirement: &73123260 !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: *73123260
36
+ - !ruby/object:Gem::Dependency
37
+ name: multi_json
38
+ requirement: &73123020 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *73123020
47
+ description: Unofficial VKontakte strategy for OmniAuth 1.0
48
+ email:
49
+ - anton.linux@gmail.com
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - README.md
55
+ - Rakefile
56
+ - examples/sinatra.rb
57
+ - lib/omniauth-vkontakte.rb
58
+ - lib/omniauth-vkontakte/version.rb
59
+ - lib/omniauth/strategies/vkontakte.rb
60
+ - omniauth-vkontakte.gemspec
61
+ homepage: https://github.com/mamantoha/omniauth-vkontakte
62
+ licenses: []
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ! '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubyforge_project:
81
+ rubygems_version: 1.8.10
82
+ signing_key:
83
+ specification_version: 3
84
+ summary: Unofficial VKontakte strategy for OmniAuth 1.0
85
+ test_files: []