omniauth-ebay 0.9.4 → 1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -1
- data/README.md +4 -2
- data/lib/ebay_api.rb +22 -3
- data/lib/omniauth-ebay/version.rb +1 -1
- data/lib/omniauth/strategies/ebay.rb +2 -3
- data/spec/lib/ebay_api_spec.rb +43 -21
- metadata +2 -2
data/.rvmrc
CHANGED
@@ -1 +1 @@
|
|
1
|
-
rvm --create use 1.9.3@omniauth-ebay
|
1
|
+
rvm --create use ruby-1.9.3-p362@omniauth-ebay
|
data/README.md
CHANGED
@@ -17,13 +17,15 @@ Note: The examples are for a Rails 3 app.
|
|
17
17
|
|
18
18
|
```ruby
|
19
19
|
Rails.application.config.middleware.use OmniAuth::Builder do
|
20
|
-
provider :ebay, "runame", "devid", "appid", "certid", "siteid", "
|
20
|
+
provider :ebay, "runame", "devid", "appid", "certid", "siteid", "environment", "auth_type"
|
21
21
|
end
|
22
22
|
```
|
23
23
|
|
24
24
|
Insert your app credentials in the given order. You can find out these details by going into your developer's account at [eBay DevZone](https://developer.ebay.com/DevZone/account/)
|
25
25
|
|
26
|
-
`
|
26
|
+
`environment` - Defaults to `:production` and other valid option is `:sandbox`
|
27
|
+
|
28
|
+
`auth_type` - An optional argument when initializing the strategy, by default it's configured to SSO(SingleSignOn),
|
27
29
|
and should be changed to AuthType::Simple (SignIn), as it's the standard option.
|
28
30
|
|
29
31
|
* To use the strategy, you will need to access it's omniauth provider path: `/auth/ebay`. The callback phase path is the default one: `/auth/ebay/callback`.
|
data/lib/ebay_api.rb
CHANGED
@@ -13,7 +13,27 @@ module EbayAPI
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
|
16
|
+
EBAY_PRODUCTION_LOGIN_URL = "https://signin.ebay.com/ws/eBayISAPI.dll"
|
17
|
+
EBAY_SANDBOX_LOGIN_URL = "https://signin.sandbox.ebay.com/ws/eBayISAPI.dll"
|
18
|
+
|
19
|
+
EBAY_PRODUCTION_XML_API_URL = "https://api.ebay.com/ws/api.dll"
|
20
|
+
EBAY_SANDBOX_XML_API_URL = "https://api.sandbox.ebay.com/ws/api.dll"
|
21
|
+
|
22
|
+
|
23
|
+
def sandbox?
|
24
|
+
options.environment == :sandbox
|
25
|
+
end
|
26
|
+
|
27
|
+
def login_url
|
28
|
+
return EBAY_SANDBOX_LOGIN_URL if sandbox?
|
29
|
+
EBAY_PRODUCTION_LOGIN_URL
|
30
|
+
end
|
31
|
+
|
32
|
+
def api_url
|
33
|
+
return EBAY_SANDBOX_XML_API_URL if sandbox?
|
34
|
+
EBAY_PRODUCTION_XML_API_URL
|
35
|
+
end
|
36
|
+
|
17
37
|
X_EBAY_API_REQUEST_CONTENT_TYPE = 'text/xml'
|
18
38
|
X_EBAY_API_COMPATIBILITY_LEVEL = '675'
|
19
39
|
X_EBAY_API_GETSESSIONID_CALL_NAME = 'GetSessionID'
|
@@ -83,7 +103,6 @@ module EbayAPI
|
|
83
103
|
end
|
84
104
|
|
85
105
|
def ebay_login_url(session_id, ruparams={})
|
86
|
-
login_url = options.loginurl || EBAY_LOGIN_URL
|
87
106
|
url = "#{login_url}?#{options.auth_type}&runame=#{options.runame}&#{session_id_field_name}=#{URI.escape(session_id).gsub('+', '%2B')}"
|
88
107
|
|
89
108
|
ruparams[:internal_return_to] = internal_return_to if internal_return_to
|
@@ -97,7 +116,7 @@ module EbayAPI
|
|
97
116
|
|
98
117
|
def api(call_name, request)
|
99
118
|
headers = ebay_request_headers(call_name, request.length.to_s)
|
100
|
-
url = URI.parse(
|
119
|
+
url = URI.parse(api_url)
|
101
120
|
req = Net::HTTP::Post.new(url.path, headers)
|
102
121
|
http = Net::HTTP.new(url.host, url.port)
|
103
122
|
http.use_ssl = true
|
@@ -14,16 +14,15 @@ module OmniAuth
|
|
14
14
|
SIMPLE_SID_FIELD_NAME = "SessId"
|
15
15
|
end
|
16
16
|
|
17
|
-
args [:runame, :devid, :appid, :certid, :siteid, :
|
17
|
+
args [:runame, :devid, :appid, :certid, :siteid, :environment, :auth_type]
|
18
18
|
option :name, "ebay"
|
19
19
|
option :runame, nil
|
20
20
|
option :devid, nil
|
21
21
|
option :appid, nil
|
22
22
|
option :certid, nil
|
23
23
|
option :siteid, nil
|
24
|
-
option :
|
24
|
+
option :environment, :production
|
25
25
|
option :auth_type, AuthType::SSO
|
26
|
-
option :loginurl, nil
|
27
26
|
|
28
27
|
uid { raw_info['EIASToken'] }
|
29
28
|
info do
|
data/spec/lib/ebay_api_spec.rb
CHANGED
@@ -32,40 +32,62 @@ describe EbayAPI do
|
|
32
32
|
subject.ebay_login_url(unescaped_session_id).should include("sid=#{CGI.escape(unescaped_session_id)}")
|
33
33
|
end
|
34
34
|
|
35
|
-
context :
|
36
|
-
it "should return ebay login
|
35
|
+
context :sandbox do
|
36
|
+
it "should return the sandbox ebay login/api urls when sandbox environment is specified" do
|
37
37
|
subject.stub(:internal_return_to) { internal_return_to }
|
38
38
|
params = {}
|
39
39
|
params[:internal_return_to] = internal_return_to
|
40
40
|
params[:sid] = session_id
|
41
|
-
subject.
|
42
|
-
|
43
|
-
|
44
|
-
it "should return ebay login url without internal return to when internal_return_to isn't given in request" do
|
45
|
-
subject.stub(:internal_return_to) { false }
|
46
|
-
params = {}
|
47
|
-
params[:sid] = session_id
|
48
|
-
subject.ebay_login_url(session_id).should == "#{EbayAPI::EBAY_LOGIN_URL}?#{singleSignOn}&runame=runame&sid=#{session_id}&ruparams=#{to_query(params)}"
|
41
|
+
subject.options.environment = :sandbox
|
42
|
+
subject.login_url.should == EbayAPI::EBAY_SANDBOX_LOGIN_URL
|
43
|
+
subject.api_url.should == EbayAPI::EBAY_SANDBOX_XML_API_URL
|
49
44
|
end
|
50
45
|
end
|
51
46
|
|
52
|
-
context :
|
53
|
-
|
54
|
-
subject.options.auth_type = OmniAuth::Strategies::Ebay::AuthType::Simple
|
55
|
-
end
|
56
|
-
it "should return ebay login url with internal_return_to when internal_return_to given in request" do
|
47
|
+
context :production do
|
48
|
+
it "should return the production login/api urls when production environment is specified" do
|
57
49
|
subject.stub(:internal_return_to) { internal_return_to }
|
58
50
|
params = {}
|
59
51
|
params[:internal_return_to] = internal_return_to
|
60
52
|
params[:sid] = session_id
|
61
|
-
subject.
|
53
|
+
subject.login_url.should == EbayAPI::EBAY_PRODUCTION_LOGIN_URL
|
54
|
+
subject.api_url.should == EbayAPI::EBAY_PRODUCTION_XML_API_URL
|
55
|
+
end
|
56
|
+
context :SingleSignOn do
|
57
|
+
it "should return ebay login url with internal return to when internal_return_to given in request" do
|
58
|
+
subject.stub(:internal_return_to) { internal_return_to }
|
59
|
+
params = {}
|
60
|
+
params[:internal_return_to] = internal_return_to
|
61
|
+
params[:sid] = session_id
|
62
|
+
subject.ebay_login_url(session_id).should == "#{EbayAPI::EBAY_PRODUCTION_LOGIN_URL}?#{singleSignOn}&runame=runame&sid=#{session_id}&ruparams=#{to_query(params)}"
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should return ebay login url without internal return to when internal_return_to isn't given in request" do
|
66
|
+
subject.stub(:internal_return_to) { false }
|
67
|
+
params = {}
|
68
|
+
params[:sid] = session_id
|
69
|
+
subject.ebay_login_url(session_id).should == "#{EbayAPI::EBAY_PRODUCTION_LOGIN_URL}?#{singleSignOn}&runame=runame&sid=#{session_id}&ruparams=#{to_query(params)}"
|
70
|
+
end
|
62
71
|
end
|
63
72
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
73
|
+
context :SignIn do
|
74
|
+
before :each do
|
75
|
+
subject.options.auth_type = OmniAuth::Strategies::Ebay::AuthType::Simple
|
76
|
+
end
|
77
|
+
it "should return ebay login url with internal_return_to when internal_return_to given in request" do
|
78
|
+
subject.stub(:internal_return_to) { internal_return_to }
|
79
|
+
params = {}
|
80
|
+
params[:internal_return_to] = internal_return_to
|
81
|
+
params[:sid] = session_id
|
82
|
+
subject.ebay_login_url(session_id).should == "#{EbayAPI::EBAY_PRODUCTION_LOGIN_URL}?#{signIn}&runame=runame&SessId=#{session_id}&ruparams=#{to_query(params)}"
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should return ebay login url without internal return to when internal_return_to isn't given in request" do
|
86
|
+
subject.stub(:internal_return_to) { false }
|
87
|
+
params = {}
|
88
|
+
params[:sid] = session_id
|
89
|
+
subject.ebay_login_url(session_id).should == "#{EbayAPI::EBAY_PRODUCTION_LOGIN_URL}?#{signIn}&runame=runame&SessId=#{session_id}&ruparams=#{to_query(params)}"
|
90
|
+
end
|
69
91
|
end
|
70
92
|
end
|
71
93
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-ebay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0
|
4
|
+
version: '1.0'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-04-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: omniauth
|