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: 91669d6758878744840643e370d369fa246a8eeb400b9cdba988ea35ab9cb6a8
4
- data.tar.gz: 52fe483b8c95cdd011f070457a06f0a7a1c5704defbf5ed47dc48aa3a274cc36
3
+ metadata.gz: cea19e4b210768c9b76023ad072499cfb20e97e46797f8a7ef2b7caec39dfe25
4
+ data.tar.gz: 308a306de3280c6eed9f0f75eca1919fa9bdbc6d426f7bb4b398ebf4146fcd18
5
5
  SHA512:
6
- metadata.gz: ae0ceebc7fca5fbbca32065cb9c57d653cf794ba874d267ad1d9df60e2bc7e2e444d7b056fe5e2c3d10013eae8a6c5ac86d08ab8445d510e4f3736e7da7b2163
7
- data.tar.gz: 2f88893066e0f750cc06a865c7a932a7b72aa881f929c137246d1aaec11c0a400dca2285341235326c0f9b03f18543436e6311241ffb2a7a6bff8a1321df0d6e
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
- uid { raw_info['store_id'] || raw_info['id'] }
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
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAuth
4
4
  module UberEatsOauth2
5
- VERSION = '0.1.0'
5
+ VERSION = '0.2.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-uber-eats-oauth2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - dan1d