omniauth-uber-eats-oauth2 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cea19e4b210768c9b76023ad072499cfb20e97e46797f8a7ef2b7caec39dfe25
|
|
4
|
+
data.tar.gz: 308a306de3280c6eed9f0f75eca1919fa9bdbc6d426f7bb4b398ebf4146fcd18
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7350e7c0c56a3786c6743afbc75be6b186a83e2fd74f27e7c1a5bbd474ed44a2ca35335f5d31eeef204d9370589c3bf70994378c1ea3282754c6b6c4f5d487e4
|
|
7
|
+
data.tar.gz: 6805ee5e9e3d1e9adf72f3db8c8a9ba19e4fe2aecd812f344beba03591dc12f6db5304b0e0ef9f463a3b8274f586fbc23810e6e897031c4c5e028f6dc49bc003
|
|
@@ -38,6 +38,26 @@ module OmniAuth
|
|
|
38
38
|
|
|
39
39
|
option :sandbox, false
|
|
40
40
|
|
|
41
|
+
# Sandbox/production URL switching.
|
|
42
|
+
# When sandbox: true, all URLs point to Uber's sandbox environment.
|
|
43
|
+
SANDBOX_URLS = {
|
|
44
|
+
site: 'https://test-api.uber.com',
|
|
45
|
+
authorize_url: 'https://sandbox-login.uber.com/oauth/v2/authorize',
|
|
46
|
+
token_url: 'https://sandbox-login.uber.com/oauth/v2/token'
|
|
47
|
+
}.freeze
|
|
48
|
+
|
|
49
|
+
PRODUCTION_URLS = {
|
|
50
|
+
site: 'https://api.uber.com',
|
|
51
|
+
authorize_url: 'https://auth.uber.com/oauth/v2/authorize',
|
|
52
|
+
token_url: 'https://auth.uber.com/oauth/v2/token'
|
|
53
|
+
}.freeze
|
|
54
|
+
|
|
55
|
+
def setup_phase
|
|
56
|
+
super
|
|
57
|
+
urls = options.sandbox ? SANDBOX_URLS : PRODUCTION_URLS
|
|
58
|
+
options.client_options.merge!(urls)
|
|
59
|
+
end
|
|
60
|
+
|
|
41
61
|
# Override to strip query params from callback_url for redirect_uri matching.
|
|
42
62
|
def build_access_token
|
|
43
63
|
redirect_uri = callback_url.sub(/\?.*/, '')
|
|
@@ -53,12 +73,15 @@ module OmniAuth
|
|
|
53
73
|
raise
|
|
54
74
|
end
|
|
55
75
|
|
|
56
|
-
|
|
76
|
+
# UID: prefer store_id from API, fall back to uber_user_id from token
|
|
77
|
+
uid do
|
|
78
|
+
raw_info['store_id'] || raw_info['id'] || uber_user_id
|
|
79
|
+
end
|
|
57
80
|
|
|
58
81
|
info do
|
|
59
82
|
{
|
|
60
|
-
name: raw_info['store_name'],
|
|
61
|
-
business_name: raw_info['store_name'],
|
|
83
|
+
name: raw_info['store_name'] || "Uber Eats Store",
|
|
84
|
+
business_name: raw_info['store_name'] || "Uber Eats Store",
|
|
62
85
|
email: nil # Uber Eats doesn't provide merchant email via API
|
|
63
86
|
}
|
|
64
87
|
end
|
|
@@ -73,9 +96,20 @@ module OmniAuth
|
|
|
73
96
|
|
|
74
97
|
private
|
|
75
98
|
|
|
99
|
+
# Extract user ID from the access token response.
|
|
100
|
+
# Uber's token response includes uber_user_id or we can derive from token params.
|
|
101
|
+
def uber_user_id
|
|
102
|
+
return @uber_user_id if defined?(@uber_user_id)
|
|
103
|
+
|
|
104
|
+
@uber_user_id = access_token.params['uber_user_id'] ||
|
|
105
|
+
access_token.params['user_id'] ||
|
|
106
|
+
access_token.token&.first(32) # last resort: use token prefix as stable ID
|
|
107
|
+
end
|
|
108
|
+
|
|
76
109
|
def fetch_store_info
|
|
77
110
|
response = access_token.get('/v1/eats/stores')
|
|
78
111
|
parsed = response.parsed
|
|
112
|
+
log(:info, "Store info response: #{parsed.inspect}")
|
|
79
113
|
stores = parsed['stores'] || []
|
|
80
114
|
store = stores.first
|
|
81
115
|
|
|
@@ -87,10 +121,11 @@ module OmniAuth
|
|
|
87
121
|
'status' => store['status']
|
|
88
122
|
}
|
|
89
123
|
else
|
|
124
|
+
log(:warn, "No stores found in response, using fallback UID")
|
|
90
125
|
{ 'store_id' => nil }
|
|
91
126
|
end
|
|
92
127
|
rescue StandardError => e
|
|
93
|
-
log(:warn, "Failed to fetch store info: #{e.message}")
|
|
128
|
+
log(:warn, "Failed to fetch store info: #{e.message} — using fallback UID")
|
|
94
129
|
{ 'store_id' => nil }
|
|
95
130
|
end
|
|
96
131
|
|