omniauth-hyves 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
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-hyves.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,8 @@
1
+ The MIT License (MIT)
2
+ Copyright © 2012 SocialReferral
3
+
4
+ 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:
5
+
6
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7
+
8
+ 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/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # OmniAuth Hyves
2
+
3
+ OAuth 1 strategy to authenticate with [Hyves](http://www.hyves.nl) to make use of the Hyves Data-API. Hyves documentation can be found [here](http://www.hyves-developers.nl/documentation/data-api/hyves-api-oauth/).
4
+
5
+ ## Usage
6
+
7
+ Use like it like any other OmniAuth strategy.
8
+
9
+ To allow the use of the various Data-API methods you need to specify them when getting the request token, you can do so by specifying them in options.request_params[:methods] (the default and minimum required is 'users.get,friends.get,media.get').
10
+
11
+ ## Development
12
+ - Source hosted on [GitHub](https://github.com)
13
+ - Please report issues and feature requests using [GitHub issues](https://github.com/socialreferral/omniauth-hyves/issues)
14
+
15
+ Pull requests are welcome, please make sure your patches are well tested before contributing. When sending a pull request:
16
+
17
+ - Use a topic branch for your change
18
+ - Do not change the version number
19
+
20
+ ## License
21
+ OmniAuth Hyves is released under the MIT license.
22
+
23
+ ## Author
24
+ [Mark Kremer](https://github.com/mkremer)
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Hyves
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require 'omniauth/hyves/version'
2
+ require 'omniauth/strategies/hyves'
@@ -0,0 +1,43 @@
1
+ require 'omniauth-oauth'
2
+ require 'multi_xml'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class Hyves < OmniAuth::Strategies::OAuth
7
+ option :client_options, {
8
+ :site => "https://data.hyves-api.nl",
9
+ :request_token_path => '/?ha_method=auth.requesttoken&ha_version=2.0&ha_format=xml&ha_fancylayout=false&strict_oauth_spec_response=true',
10
+ :authorize_url => 'http://www.hyves.nl/api/authorize/',
11
+ :access_token_path => '/?ha_method=auth.accesstoken&ha_version=2.0&ha_format=xml&ha_fancylayout=false&strict_oauth_spec_response=true',
12
+ :scheme => :query_string
13
+ }
14
+
15
+ option :request_params, {:methods => 'users.get,friends.get,media.get', :expirationtype => 'infinite'}
16
+
17
+ uid do
18
+ access_token.params["userid"]
19
+ end
20
+
21
+ info do
22
+ {
23
+ name: "#{user_info["firstname"]} #{user_info["lastname"]}",
24
+ first_name: user_info["firstname"],
25
+ last_name: user_info["lastname"],
26
+ image: user_image
27
+ }
28
+ end
29
+
30
+ private
31
+
32
+ def user_info
33
+ @user_info ||= MultiXml.parse(access_token.get("/?ha_version=2.0&ha_method=users.get&userid=#{uid}").body)["users_get_result"]["user"]
34
+ end
35
+
36
+ def user_image
37
+ media_info = MultiXml.parse(access_token.get("/?ha_version=2.0&ha_method=media.get&mediaid=#{user_info["mediaid"]}").body)
38
+ url = media_info["media_get_result"]["media"]["image"]["src"]
39
+ url =~ /^http.*/ ? url : nil
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1 @@
1
+ require "omniauth/hyves"
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "omniauth/hyves/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "omniauth-hyves"
7
+ s.version = Omniauth::Hyves::VERSION
8
+ s.authors = ["Mark Kremer"]
9
+ s.email = ["mark@socialreferral.com"]
10
+ s.summary = %q{Hyves strategy for OmniAuth}
11
+
12
+ s.files = `git ls-files`.split("\n")
13
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
15
+ s.require_paths = ["lib"]
16
+
17
+ s.add_runtime_dependency 'omniauth-oauth', '~> 1.0'
18
+ s.add_runtime_dependency 'multi_xml', '~> 0.4.1'
19
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-hyves
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Mark Kremer
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-05 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth-oauth
16
+ requirement: &23488220 !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: *23488220
25
+ - !ruby/object:Gem::Dependency
26
+ name: multi_xml
27
+ requirement: &23501980 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 0.4.1
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *23501980
36
+ description:
37
+ email:
38
+ - mark@socialreferral.com
39
+ executables: []
40
+ extensions: []
41
+ extra_rdoc_files: []
42
+ files:
43
+ - .gitignore
44
+ - Gemfile
45
+ - LICENSE.txt
46
+ - README.md
47
+ - Rakefile
48
+ - lib/omniauth-hyves.rb
49
+ - lib/omniauth/hyves.rb
50
+ - lib/omniauth/hyves/version.rb
51
+ - lib/omniauth/strategies/hyves.rb
52
+ - omniauth-hyves.gemspec
53
+ homepage:
54
+ licenses: []
55
+ post_install_message:
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubyforge_project:
73
+ rubygems_version: 1.8.11
74
+ signing_key:
75
+ specification_version: 3
76
+ summary: Hyves strategy for OmniAuth
77
+ test_files: []