Skip to content

Commit 6532077

Browse files
Merge pull request #5 from ShippingEasy/ke/update_token_auth
Update token_url with store_id provided in callback request
2 parents 6710b6a + e4e42f6 commit 6532077

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/omniauth/strategies/ecwid.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ class Ecwid < OmniAuth::Strategies::OAuth2
77
option :name, "ecwid"
88
option :client_options, {
99
:site => 'https://my.ecwid.com',
10-
:authorize_url => '/api/oauth/authorize',
11-
:token_url => '/api/oauth/token'
10+
:authorize_url => '/api/oauth/authorize'
1211
}
1312

1413
# scope: "read_orders update_catalog", etc
@@ -18,6 +17,15 @@ class Ecwid < OmniAuth::Strategies::OAuth2
1817
uid {
1918
access_token.params.fetch("store_id")
2019
}
20+
21+
protected
22+
23+
# Override to set token_url with store_id from callback params
24+
def build_access_token
25+
store_id = request.params['store_id']
26+
options.client_options[:token_url] = "/api/oauth/token/#{store_id}"
27+
super
28+
end
2129
end
2230
end
2331
end

0 commit comments

Comments
 (0)