omniauth-linkedin 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,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ *.swp
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm 1.9.2@omniauth-linkedin
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in omniauth-linkedin.gemspec
4
+ gemspec
5
+
6
+ gem 'omniauth-oauth', :git => 'https://github.com/intridea/omniauth-oauth.git'
data/README.md ADDED
@@ -0,0 +1,68 @@
1
+ # OmniAuth LinkedIn
2
+
3
+ **Note:** This gem is designed to work with the unreleased OmniAuth 1.0 library. It will not be officially released on RubyGems.org until OmniAuth 1.0 is released.
4
+
5
+ This gem contains the LinkedIn strategy for OmniAuth.
6
+
7
+ LinkedIn uses the OAuth 1.0a flow, you can read about it here: https://developer.linkedin.com/documents/authentication
8
+
9
+ ## How To Use It
10
+
11
+ Usage is as per any other OmniAuth 1.0 strategy. So let's say you're using Rails, you need to add the strategy to your `Gemfile` along side omniauth:
12
+
13
+ gem 'omniauth'
14
+ gem 'omniauth-linkedin'
15
+
16
+ Of course if one or both of these are unreleased, you may have to pull them in directly from github e.g.:
17
+
18
+ gem 'omniauth', :git => 'https://github.com/intridea/omniauth.git'
19
+ gem 'omniauth-linkedin', :git => 'https://github.com/skorks/omniauth-linkedin.git'
20
+
21
+ Once these are in, you need to add the following to your `config/initializers/omniauth.rb`:
22
+
23
+ Rails.application.config.middleware.use OmniAuth::Builder do
24
+ provider :linkedin, "consumer_key", "consumer_secret"
25
+ end
26
+
27
+ You will obviously have to put in your key and secret, which you get when you register your app with LinkedIn (they call them API Key and Secret Key).
28
+
29
+ Now just follow the README at: https://github.com/intridea/omniauth
30
+
31
+ ## Using It With The LinkedIn Gem
32
+
33
+ You may find that you want to use OmniAuth for authentication, but you want to use an API wrapper such as this one https://github.com/pengwynn/linkedin to actually make your api calls. But the LinkedIn gem provides it's own way to authenticate with LinkedIn via OAuth. In this case you can do the following.
34
+
35
+ Configure the LinkedIn gem with your consumer key and secret:
36
+
37
+ LinkedIn.configure do |config|
38
+ config.token = "consumer_key"
39
+ config.secret = "consumer_secret"
40
+ end
41
+
42
+ Use OmniAuth as per normal to obtain an access token and an access token secret for your user. Now create the LinkedIn client and authorize it using the access token and secret that you ontained via OmniAuth:
43
+
44
+ client = LinkedIn::Client.new
45
+ client.authorize_from_access("access_token", "access_token_secret")
46
+
47
+ You can now make API calls as per normal e.g.:
48
+
49
+ client.profile
50
+ client.add_share({:comment => "blah"})
51
+
52
+ ## Note on Patches/Pull Requests
53
+
54
+ - Fork the project.
55
+ - Make your feature addition or bug fix.
56
+ - Add tests for it. This is important so I don’t break it in a future version unintentionally.
57
+ - Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
58
+ - Send me a pull request. Bonus points for topic branches.
59
+
60
+ ## License
61
+
62
+ Copyright (c) 2011 by Alan Skorkin
63
+
64
+ 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:
65
+
66
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
67
+
68
+ 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,9 @@
1
+ require "omniauth-linkedin/version"
2
+ require 'omniauth/strategies/linkedin'
3
+
4
+
5
+ module Omniauth
6
+ module Linkedin
7
+ # Your code goes here...
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Linkedin
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,43 @@
1
+ require 'omniauth/strategies/oauth'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class LinkedIn < OmniAuth::Strategies::OAuth
6
+ option :name, "linkedin"
7
+
8
+ option :client_options, {
9
+ :site => 'https://api.linkedin.com',
10
+ :request_token_path => '/uas/oauth/requestToken',
11
+ :access_token_path => '/uas/oauth/accessToken',
12
+ :authorize_url => 'https://www.linkedin.com/uas/oauth/authenticate'
13
+ }
14
+
15
+ option :fields, ["id", "first-name", "last-name", "headline", "industry", "picture-url", "public-profile-url"]
16
+
17
+ uid{ raw_info['id'] }
18
+
19
+ info do
20
+ {
21
+ :first_name => raw_info['firstName'],
22
+ :last_name => raw_info['lastName'],
23
+ :headline => raw_info['headline'],
24
+ :image => raw_info['pictureUrl'],
25
+ :industry => raw_info['industry'],
26
+ :urls => {
27
+ 'public_profile' => raw_info['publicProfileUrl']
28
+ }
29
+ }
30
+ end
31
+
32
+ extra do
33
+ { 'raw_info' => raw_info }
34
+ end
35
+
36
+ def raw_info
37
+ @raw_info ||= MultiJson.decode(access_token.get("/v1/people/~:(#{options.fields.join(',')})?format=json").body)
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ OmniAuth.config.add_camelization 'linkedin', 'LinkedIn'
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "omniauth-linkedin/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "omniauth-linkedin"
7
+ s.version = Omniauth::Linkedin::VERSION
8
+ s.authors = ["Alan Skorkin"]
9
+ s.email = ["alan@skorks.com"]
10
+ s.homepage = "https://github.com/skorks/omniauth-linkedin"
11
+ s.summary = %q{LinkedIn strategy for OmniAuth.}
12
+ s.description = %q{LinkedIn strategy for OmniAuth.}
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+
19
+ s.add_runtime_dependency 'omniauth-oauth', '~> 1.0.0.rc2'
20
+
21
+ s.add_development_dependency 'rspec', '~> 2.6.0'
22
+ s.add_development_dependency 'rake'
23
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-linkedin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Alan Skorkin
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-11-04 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth-oauth
16
+ requirement: &70115253187640 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.0.0.rc2
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70115253187640
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ requirement: &70115253186960 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 2.6.0
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70115253186960
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ requirement: &70115253186320 !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: *70115253186320
47
+ description: LinkedIn strategy for OmniAuth.
48
+ email:
49
+ - alan@skorks.com
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .gitignore
55
+ - .rvmrc
56
+ - Gemfile
57
+ - README.md
58
+ - Rakefile
59
+ - lib/omniauth-linkedin.rb
60
+ - lib/omniauth-linkedin/version.rb
61
+ - lib/omniauth/strategies/linkedin.rb
62
+ - omniauth-linkedin.gemspec
63
+ homepage: https://github.com/skorks/omniauth-linkedin
64
+ licenses: []
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ segments:
76
+ - 0
77
+ hash: -4021008711059361796
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ! '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ segments:
85
+ - 0
86
+ hash: -4021008711059361796
87
+ requirements: []
88
+ rubyforge_project:
89
+ rubygems_version: 1.8.6
90
+ signing_key:
91
+ specification_version: 3
92
+ summary: LinkedIn strategy for OmniAuth.
93
+ test_files: []