omniauth-upwork 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2ee297312d3760a70e665c468c3218f7a4cabdab
4
+ data.tar.gz: a6a7209c54209d1effa40ec6a663eded65552055
5
+ SHA512:
6
+ metadata.gz: ae4a7f90f1339f8a53ccef104ec9c2d36ea54e7dda50f688e2291d2f2b50208e1d2319bbf0e9c0fb36019737276ae9f8e9cfb7d8479da1b418ae7fcef522cf2f
7
+ data.tar.gz: da4632be82d891c2e6db7eaa9b895efbdb5bab65592b5961c6f4897e17654aa6a80e8f5a79d36c68326d047b3ffffa06579e3ba4e08bdd7fd097813df1a19e7d
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ # See http://help.github.com/ignore-files/ for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile ~/.gitignore_global
6
+
7
+ Gemfile.lock
8
+ .project
9
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-oauth2.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,77 @@
1
+ omniauth-upwork
2
+ ===============
3
+
4
+ Upwork Developer API OAuth 1.0 Strategy for OmniAuth.
5
+
6
+ Supports the OAuth 1.0 server-side and client-side flows. Read the [Upwork Developer API docs](https://developers.upwork.com/#authentication_oauth-10) for more details.
7
+
8
+ ## Installing
9
+
10
+ Add to your `Gemfile`:
11
+
12
+ ```ruby
13
+ gem 'omniauth-upwork'
14
+ ```
15
+
16
+ Then `bundle install`.
17
+
18
+ ## Usage
19
+
20
+ `OmniAuth::Strategies::Upwork` is simply a Rack middleware.Read the [OmniAuth 1.0](https://github.com/intridea/omniauth) and [OAuth 2.0](https://github.com/intridea/oauth2) docs for detailed instructions
21
+
22
+ Here's a quick example, adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
23
+
24
+ ```ruby
25
+ Rails.application.config.middleware.use OmniAuth::Builder do
26
+ provider :upwork, ENV['UPWORK_CONSUMER_KEY'], ENV['UPWORK_CONSUMER_SECRET']
27
+ end
28
+ ```
29
+
30
+ ## Examples
31
+ Standalone usage from a Ruby script samples can be found under `examples` folder.
32
+
33
+ ## Auth Hash
34
+
35
+ Here's an example [Auth Hash](https://github.com/intridea/omniauth/wiki/Auth-Hash-Schema) available in `request.env['omniauth.auth']`:
36
+
37
+ ```ruby
38
+ {
39
+ :provider => 'upwork',
40
+ :uid => '1234567',
41
+ :info => {
42
+ first_name: 'First Name',
43
+ last_name: 'Last Name',
44
+ email: 'email@upwork.com',
45
+ status: 'active',
46
+ profile_key: 'profile_key'
47
+ },
48
+ :credentials => {
49
+ :token => 'ABCDEF...', # access token, which you may wish to store
50
+ :secret => '1321747205', # access token secret
51
+ },
52
+ :extra => {
53
+ :raw_info => {
54
+ id: "4124672",
55
+ status: "active",
56
+ timezone: "UTC+02:00 Eastern Europe",
57
+ timezone_offset: "10800"
58
+ public_url: 'https://www.upwork.com/users/~~kyad0112d885630b',
59
+ last_name: 'Novozhylov',
60
+ email: 'myemail@upwork.com',
61
+ reference: "12345",
62
+ first_name: "Maksym",
63
+ profile_key: "~~kyad0112d885630b",
64
+ is_provider: '1'
65
+ }
66
+ }
67
+ ```
68
+
69
+ ## License
70
+
71
+ Copyright (c) 2013 by Jignesh Gohel
72
+
73
+ 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:
74
+
75
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
76
+
77
+ 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.
@@ -0,0 +1,2 @@
1
+ require 'omniauth-upwork/version'
2
+ require 'omniauth/strategies/upwork'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Upwork
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,50 @@
1
+ require 'omniauth-oauth'
2
+ require 'json'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class Upwork < OmniAuth::Strategies::OAuth
7
+ # Strategy name
8
+ option :name, "upwork"
9
+
10
+ # Options being passed to initialize client from the OAuth Gem.
11
+ # Reference: https://github.com/oauth-xx/oauth-ruby
12
+ option :client_options, {
13
+ site: "https://www.upwork.com",
14
+ request_token_path: "/api/auth/v1/oauth/token/request",
15
+ authorize_path: "/services/api/auth",
16
+ access_token_path: "/api/auth/v1/oauth/token/access"
17
+ }
18
+
19
+ # Called after authentication has succeeded.
20
+ uid {
21
+ raw_info['id']
22
+ }
23
+
24
+ info do
25
+ {
26
+ first_name: raw_info['first_name'],
27
+ last_name: raw_info['last_name'],
28
+ email: raw_info['email'],
29
+ status: raw_info['status'],
30
+ profile_key: raw_info['profile_key']
31
+ }
32
+ end
33
+
34
+ extra do
35
+ {
36
+ 'raw_info' => raw_info
37
+ }
38
+ end
39
+
40
+ def raw_info
41
+ # Reference: https://www.elance.com/q/api2/methods/profiles/my
42
+ raw_info = access_token.get('/api/hr/v2/users/me.json')
43
+
44
+ data = raw_info.read_body
45
+ data = (data ? JSON.parse(data) : {} )
46
+ data['user'] || {}
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/omniauth-upwork/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.add_dependency 'omniauth-oauth', '~> 1.1.0'
6
+ gem.add_dependency 'json', '~> 1.8.0'
7
+
8
+ gem.authors = ["Jignesh Gohel", "Mahmoud Ali"]
9
+ gem.email = ["jignesh.gohel@botreeconsulting.com"]
10
+ gem.description = %q{Upwork strategy for OmniAuth.}
11
+ gem.summary = %q{Upwork strategy for OmniAuth.}
12
+ gem.homepage = "https://github.com/m7moud/omniauth-upwork"
13
+ gem.license = "MIT"
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-upwork"
19
+ gem.require_paths = ["lib"]
20
+ gem.version = OmniAuth::Upwork::VERSION
21
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-upwork
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jignesh Gohel
8
+ - Mahmoud Ali
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-07-28 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth-oauth
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: 1.1.0
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: 1.1.0
28
+ - !ruby/object:Gem::Dependency
29
+ name: json
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: 1.8.0
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: 1.8.0
42
+ description: Upwork strategy for OmniAuth.
43
+ email:
44
+ - jignesh.gohel@botreeconsulting.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - Gemfile
51
+ - README.md
52
+ - lib/omniauth-upwork.rb
53
+ - lib/omniauth-upwork/version.rb
54
+ - lib/omniauth/strategies/upwork.rb
55
+ - omniauth-upwork.gemspec
56
+ homepage: https://github.com/m7moud/omniauth-upwork
57
+ licenses:
58
+ - MIT
59
+ metadata: {}
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 2.4.8
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: Upwork strategy for OmniAuth.
80
+ test_files: []