linkedin-oauth2 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YjgxY2YzOGY3OTc1ZjE3NTAzNzZmMTEyMjM3YjI2MDUxY2FkNDI1Ng==
5
+ data.tar.gz: !binary |-
6
+ MmFiMmQ0YzQwYjQzMDI2MjI0NWU3YmZjNWIzNjc0M2JlYjcwYjBmNg==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NWViNDkwYTYyMGM0ODYzYzQ2MmNiYjdmNThhZWEzYWJiNGQ1ZGNkYTE3YmE3
10
+ NGZjMGZlMThlYTU0NWUwMDdhMDRlMTYxZTdlMDA1MzkxY2FhMmE0YWUwMmU2
11
+ ZjFiNjA0NDY3YmEwNDY1MDMxOTVmYzAyMTgyYTA0OTNiOGNhNjI=
12
+ data.tar.gz: !binary |-
13
+ NGI3ZTlmOWM4OTU4MjIzOWViNWVhNmZhZGFkM2U5MDEwZDRmYzM4ODZjNWJm
14
+ Mjc4MGU3YWEyOWNjNDgwZjZlNTZjMWFlY2RjNTliYmU0MjdlNjViNjQ0ZTU4
15
+ ODg2MmYwNDU4ODRlMTE1NzdiN2Q2NTZlNWVlNWE1MjI3NDg3M2E=
@@ -0,0 +1,14 @@
1
+ Autotest.add_hook(:initialize) do |at|
2
+ at.add_exception(".git")
3
+ end
4
+
5
+ Autotest.add_hook(:initialize) do |at|
6
+ at.clear_mappings
7
+
8
+ at.add_mapping %r%/^lib/(.*)\.rb$% do |_, m|
9
+ possible = File.basename(m[1])
10
+ files_matching %r%^test/.*(#{possible}_test|test_#{possible})\.rb$%
11
+ end
12
+
13
+ at.add_mapping(%r%^test/.*\.rb$%) {|filename, _| filename }
14
+ end
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
File without changes
@@ -0,0 +1,41 @@
1
+ *.gem
2
+ *.rbc
3
+ *.sw[a-p]
4
+ *.tmproj
5
+ *.tmproject
6
+ *.un~
7
+ *~
8
+ .DS_Store
9
+ .Spotlight-V100
10
+ .Trashes
11
+ ._*
12
+ .bundle
13
+ .config
14
+ .directory
15
+ .elc
16
+ .redcar
17
+ .yardoc
18
+ .rvmrc
19
+ /.emacs.desktop
20
+ /.emacs.desktop.lock
21
+ Desktop.ini
22
+ Gemfile.lock
23
+ Icon?
24
+ InstalledFiles
25
+ Session.vim
26
+ Thumbs.db
27
+ \#*\#
28
+ _yardoc
29
+ auto-save-list
30
+ coverage
31
+ doc/
32
+ lib/bundler/man
33
+ pkg
34
+ pkg/*
35
+ rdoc
36
+ spec/reports
37
+ test/tmp
38
+ test/version_tmp
39
+ tmp
40
+ tmtags
41
+ tramp
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1 @@
1
+ linkedin-oauth2
@@ -0,0 +1 @@
1
+ ruby-1.9.3-p429
@@ -0,0 +1,5 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - ree
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'http://rubygems.org'
2
+
3
+ platforms :jruby do
4
+ gem 'jruby-openssl', '~> 0.7'
5
+ end
6
+
7
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Evan Morikawa
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,121 @@
1
+ # LinkedIn
2
+
3
+ Oauth 2.0 Ruby wrapper for the [LinkedIn API](http://developer.linkedin.com). Heavily inspired by [pengwynn/linkedin](https://github.com/pengwynn/linkedin)'s Oauth 1.0 Linkedin API interface. Most methods are the same as pengwynn/linkedin's gem, but major terminology changes make this incompatible.
4
+
5
+ Travis CI : [![Build Status](https://secure.travis-ci.org/emorikawa/linkedin-oauth2.png)](http://travis-ci.org/emorikawa/linkedin-oauth2)
6
+
7
+ ## Installation
8
+
9
+ [sudo] gem install linkedin-oauth2
10
+
11
+ ## Usage
12
+
13
+ ### Authenticate Overview
14
+
15
+ LinkedIn's API uses OAuth 2.0 for authentication. Luckily, this gem hides most of the gory details from you.
16
+
17
+ The gory details can be found [here](https://developer.linkedin.com/documents/authentication)
18
+
19
+ For legacy support of LinkedIn's OAuth 1.0a api, refer to the [pengwynn/linkedin](https://github.com/pengwynn/linkedin) gem.
20
+
21
+ Basically, you need 3 things to start using LinkedIn's API:
22
+
23
+ 1. Your application's `client_id` aka **API Key**
24
+ 1. Your application's `client_secret` aka **Secret Key**
25
+ 1. An `access_token` from a user who authorized your app.
26
+
27
+ ### If you already have a user's `access_token`
28
+ Then you have already authenticated! Encoded within that access token are
29
+ all of the permissions you have on a given user. Assuming you requested
30
+ the appropriate permissions, you can read their profile, grab connections,
31
+ etc.
32
+
33
+ client = LinkedIn::Client.new("<your client_id>",
34
+ "<your client_secret>",
35
+ "<user access_token>")
36
+ client.profile
37
+
38
+ You may also use the `set_access_token` method.
39
+
40
+ client.set_access_token("<user access_token>", options)
41
+
42
+ ### If you need to fetch an `access_token` for a user.
43
+ There are 4 steps:
44
+
45
+ 1. Setup a client using your application's `client_id` and `client_secret`
46
+
47
+ client = LinkedIn::Client.new('your_client_id', 'your_client_secret')
48
+
49
+ 2. Get the `authorize_url` to bring up the page that will ask a user
50
+ to verify permissions & grant you access.
51
+
52
+ authorize_url = client.authorize_url
53
+
54
+ 3. Once a user signs in to your OAuth 2.0 box, you will get an
55
+ `auth_code` aka **code**. (Check in url you were directed to after a
56
+ successful auth). Use this **auth code** to request the
57
+ **access token**.
58
+
59
+ access_token = client.request_access_token("<auth_code from last step>")
60
+
61
+ 4. Once you have an `access_token`, you can request profile information or
62
+ anything else you have permissions for.
63
+
64
+ client.profile
65
+
66
+ ### Profile examples
67
+ ```ruby
68
+ # get the profile for the authenticated user
69
+ client.profile
70
+
71
+ # get a profile for someone found in network via ID
72
+ client.profile(:id => 'gNma67_AdI')
73
+
74
+ # get a profile for someone via their public profile url
75
+ client.profile(:url => 'http://www.linkedin.com/in/netherland')
76
+ ```
77
+
78
+
79
+ More examples in the [examples folder](http://github.com/pengwynn/linkedin/blob/master/examples).
80
+
81
+ For a nice example on using this in a [Rails App](http://pivotallabs.com/users/will/blog/articles/1096-linkedin-gem-for-a-web-app).
82
+
83
+ If you want to play with the LinkedIn api without using the gem, have a look at the [apigee LinkedIn console](http://app.apigee.com/console/linkedin).
84
+
85
+ ## Migration from OAuth 1.0a to OAuth 2.0
86
+ ### Overall changes
87
+ * The term `consumer` is now referred to as the `client`
88
+ * The terms `token`, `consumer token`, or `consumer key` in OAuth 1.0 are now referred to as **`client_id`** in OAuth 2.0
89
+ * The terms `secret`, or `consumer secret` in OAuth 1.0 are now referred to as **`client_secret`** in OAuth 2.0
90
+ * In OAuth 1.0 there is both an `auth token` and an `auth secret`. OAuth 2.0 combines these into a single `access token`.
91
+ * The terms `auth token`, `auth key`, `auth secret`, `access secret`, `access token`, or `access key` have all been collapsed and are now referred to as the **`access token`**.
92
+ * `require` `linkedin-oauth2` instead of `linkedin`
93
+ * Removed proxy options
94
+
95
+ ### Gem api changes
96
+ * In general, any place that said "consumer" now says "client"
97
+ * The `authorize_from_request` method has been deprecated. Instead
98
+ navigate to the url from `authorize_url` then enter the returned code
99
+ into the `request_access_token` method.
100
+ * The `authorize_from_access` method has been deprecated. Instead
101
+ initialize the `LinkedIn::Client.new` with the `access_token`.
102
+ `client = Linkedin::Client.new(client_id, client_secret, access_token)`
103
+
104
+
105
+ ## Note on Patches/Pull Requests
106
+
107
+ * Fork the project.
108
+ * Make your feature addition or bug fix.
109
+ * Add tests for it. This is important so I don't break it in a
110
+ future version unintentionally.
111
+ * Commit, do not mess with rakefile, version, or history.
112
+ (if you want to have your own version, that is fine but
113
+ bump version in a commit by itself I can ignore when I pull)
114
+ * Send me a pull request. Bonus points for topic branches.
115
+
116
+ ## Testing
117
+ Run `bundle install`
118
+
119
+ ## Copyright
120
+
121
+ Copyright (c) 2013 [Evan Morikawa](https://twitter.com/E0M). See LICENSE for details.
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env rake
2
+
3
+ require 'bundler'
4
+ Bundler::GemHelper.install_tasks
5
+
6
+ require 'rspec/core/rake_task'
7
+ RSpec::Core::RakeTask.new(:spec)
8
+
9
+ task :test => :spec
10
+ task :default => :spec
11
+
12
+ task :compile_and_test do
13
+ puts "Compiling"
14
+ puts `gem build linkedin-oauth2.gemspec && gem install ./linkedin-oauth2*.gem`
15
+ puts "Testing"
16
+ Rake::Task["test"].invoke
17
+ end
18
+
19
+ require 'rdoc/task'
20
+ require File.expand_path('../lib/linked_in/version', __FILE__)
21
+ RDoc::Task.new do |rdoc|
22
+ rdoc.rdoc_dir = 'rdoc'
23
+ rdoc.title = "linkedin #{LinkedIn::VERSION::STRING}"
24
+ rdoc.rdoc_files.include('README*')
25
+ rdoc.rdoc_files.include('lib/**/*.rb')
26
+ end
@@ -0,0 +1,94 @@
1
+ # Changelog
2
+
3
+ # OAuth 2.0 Versions
4
+
5
+ ## 0.1.0 - July 15, 2013
6
+
7
+ * Migrated API over to use Linkedin's OAuth 2.0
8
+
9
+ # OAuth 1.0 Legacy Versions Via pengwynn/linkedin
10
+
11
+ ## 0.4.0 - May 30, 2013
12
+
13
+ * Add capability to ask for desired permissions from linked in api
14
+ * Add option to specify a proxy
15
+ * Bump hashie version
16
+ * fix the permission param passing
17
+ * fix to be able to pass the permission scope
18
+ * Manipulating comments/likes for network_updates ('shares')
19
+ * Methods to work with comments/likes for share
20
+ * Added a method to get a user's shares
21
+ * Added current user's shares as an option (client.shares)
22
+ * Readme Typos
23
+
24
+
25
+
26
+ ## 0.2.x - March x, 2010
27
+
28
+ * Removed Crack as a dependency, Nokogiri FTW
29
+
30
+ ## 0.2.1 - March 1, 2010
31
+
32
+ * Big dependency clean up, only OAuth and Nokogiri are really needed.
33
+
34
+ * Use Nokogiri for xml generation (thanks Leonid Shevtsov - leonid-shevtsov)
35
+
36
+ * Like and Likes supported
37
+
38
+ * Escape querystring args
39
+
40
+ * General coding cleanup
41
+
42
+ * Added Languages, Skills, Publications, Patents and Phone Numbers (thanks Tadas Tamošauskas - medwezys)
43
+
44
+ * Extra fields added to profile (thanks Tadas Tamošauskas - medwezys)
45
+
46
+ * public\_profile\_field added to Profile (thanks troysteinbauer)
47
+
48
+ * Added recommendations (thanks Erol)
49
+
50
+ * Added current-share
51
+
52
+ * Added default\_profile\__fields config option
53
+
54
+ ## 0.1.7 - February 5, 2010
55
+
56
+ * New group join status support JGRP from Terry Ray
57
+
58
+ ## 0.1.6 - January 20, 2010
59
+
60
+ * Fixed bug with network status update connection collections - thanks Terry Ray
61
+
62
+ ## 0.1.5 - January 13, 2010
63
+
64
+ * Added education and profile fields missing from updated LinkedIn docs
65
+
66
+ ## 0.1.4 - January 13, 2010
67
+
68
+ * Applied patch for position end month/year from @holman
69
+
70
+ ## 0.1.3 - December 24, 2009
71
+
72
+ * Added configure block for easier initialization of consumer token, secret
73
+
74
+ ## 0.1.1 - December 8, 2009
75
+
76
+ * Applied patch from [nfo](http://github.com/nfo) to fix error handling
77
+
78
+ ## 0.1.0 - November 25, 2009
79
+
80
+ * Network updates API support
81
+
82
+ * Search API support
83
+
84
+ * Updates API support
85
+
86
+ ## 0.0.2 - November 25, 2009
87
+
88
+ * Swapped out Crack for ROXML for prettier object access
89
+
90
+ * Added more tests for Profile API
91
+
92
+ ## 0.0.1 - November 24, 2009
93
+
94
+ * Initial release
@@ -0,0 +1,16 @@
1
+ require 'rubygems'
2
+ require 'linkedin'
3
+
4
+ # get your api keys at https://www.linkedin.com/secure/developer
5
+ client = LinkedIn::Client.new('your_client_id', 'your_client_secret')
6
+
7
+ # Get a url that you can enter into the browser to connect a user's
8
+ # account to your client_id and client_secret.
9
+ authorize_url = client.authorize_url
10
+
11
+ # Record the 'code' param (check the url bar) then use it to request the
12
+ # access_token.
13
+ access_token = client.request_access_token("<auth_code from last step>")
14
+
15
+ # Once you've initialized the access_token, you can call any api method
16
+ client.profile
@@ -0,0 +1,12 @@
1
+ # AUTHENTICATE FIRST found in examples/authenticate.rb
2
+
3
+ # client is a LinkedIn::Client
4
+
5
+ # get network updates for the authenticated user
6
+ client.network_updates
7
+
8
+ # get profile picture changes
9
+ client.network_updates(:type => 'PICT')
10
+
11
+ # view connections for the currently authenticated user
12
+ client.connections
@@ -0,0 +1,18 @@
1
+ # AUTHENTICATE FIRST found in examples/authenticate.rb
2
+
3
+ # client is a LinkedIn::Client
4
+
5
+ # get the profile for the authenticated user
6
+ client.profile
7
+
8
+ # get a profile for someone found in network via ID
9
+ client.profile(:id => 'gNma67_AdI')
10
+
11
+ # get a profile for someone via their public profile url
12
+ client.profile(:url => 'http://www.linkedin.com/in/netherland')
13
+
14
+ # provides the ability to access authenticated user's company field in the profile
15
+ user = client.profile(:fields => %w(positions))
16
+ companies = user.positions.all.map{|t| t.company}
17
+ # Example: most recent company can be accessed via companies[0]
18
+
@@ -0,0 +1,69 @@
1
+ require "rubygems"
2
+ require "haml"
3
+ require "sinatra"
4
+ require "linkedin"
5
+
6
+ enable :sessions
7
+
8
+ helpers do
9
+ def login?
10
+ !session[:atoken].nil?
11
+ end
12
+
13
+ def profile
14
+ linkedin_client.profile unless session[:atoken].nil?
15
+ end
16
+
17
+ def connections
18
+ linkedin_client.connections unless session[:atoken].nil?
19
+ end
20
+
21
+ private
22
+ def linkedin_client
23
+ client = LinkedIn::Client.new(settings.api, settings.secret, session[:atoken])
24
+ client
25
+ end
26
+
27
+ end
28
+
29
+ configure do
30
+ # get your api keys at https://www.linkedin.com/secure/developer
31
+ set :api, "your_api_key"
32
+ set :secret, "your_secret"
33
+ end
34
+
35
+ get "/" do
36
+ haml :index
37
+ end
38
+
39
+ get "/auth" do
40
+ client = LinkedIn::Client.new(settings.api, settings.secret)
41
+ authorize_url = client.authorize_url(redirect_uri: "http://#{request.host}:#{request.port}/auth/callback")
42
+ redirect authorize_url
43
+ end
44
+
45
+ get "/auth/logout" do
46
+ session[:atoken] = nil
47
+ redirect "/"
48
+ end
49
+
50
+ get "/auth/callback" do
51
+ client = LinkedIn::Client.new(settings.api, settings.secret)
52
+ code = params[:code]
53
+ session[:atoken] = client.request_access_token(code, redirect_uri: "/")
54
+ redirect "/"
55
+ end
56
+
57
+
58
+ __END__
59
+ @@index
60
+ -if login?
61
+ %p Welcome #{profile.first_name}!
62
+ %a{:href => "/auth/logout"} Logout
63
+ %p= profile.headline
64
+ %br
65
+ %div= "You have #{connections.total} connections!"
66
+ -connections.all.each do |c|
67
+ %div= "#{c.first_name} #{c.last_name} - #{c.headline}"
68
+ -else
69
+ %a{:href => "/auth"} Login using LinkedIn