omniauth-uber-eats-oauth2 0.1.0
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 +7 -0
- data/CHANGELOG.md +12 -0
- data/LICENSE.txt +21 -0
- data/README.md +139 -0
- data/lib/omniauth/strategies/uber_eats_oauth2.rb +104 -0
- data/lib/omniauth/uber_eats_oauth2/version.rb +7 -0
- data/lib/omniauth-uber-eats-oauth2.rb +5 -0
- metadata +149 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 91669d6758878744840643e370d369fa246a8eeb400b9cdba988ea35ab9cb6a8
|
|
4
|
+
data.tar.gz: 52fe483b8c95cdd011f070457a06f0a7a1c5704defbf5ed47dc48aa3a274cc36
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: ae0ceebc7fca5fbbca32065cb9c57d653cf794ba874d267ad1d9df60e2bc7e2e444d7b056fe5e2c3d10013eae8a6c5ac86d08ab8445d510e4f3736e7da7b2163
|
|
7
|
+
data.tar.gz: 2f88893066e0f750cc06a865c7a932a7b72aa881f929c137246d1aaec11c0a400dca2285341235326c0f9b03f18543436e6311241ffb2a7a6bff8a1321df0d6e
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.1.0] - 2026-03-16
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Initial release
|
|
8
|
+
- OmniAuth OAuth2 strategy for Uber Eats
|
|
9
|
+
- Authorization code flow with `eats.pos_provisioning` scope
|
|
10
|
+
- Store info fetching from `/v1/eats/stores`
|
|
11
|
+
- Redirect URI query param stripping for exact match
|
|
12
|
+
- Full RSpec test suite with 100% line and branch coverage
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 dan1d
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# OmniAuth Uber Eats OAuth2
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/rb/omniauth-uber-eats-oauth2)
|
|
4
|
+
[](https://github.com/dan1d/omniauth-uber-eats-oauth2/actions/workflows/ci.yml)
|
|
5
|
+
[](https://github.com/dan1d/omniauth-uber-eats-oauth2)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
An OmniAuth strategy for authenticating with [Uber Eats](https://developer.uber.com/docs/eats) using OAuth 2.0.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
Add this line to your application's Gemfile:
|
|
13
|
+
|
|
14
|
+
```ruby
|
|
15
|
+
gem 'omniauth-uber-eats-oauth2'
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
And then execute:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
bundle install
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Or install it yourself as:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
gem install omniauth-uber-eats-oauth2
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
### Rails / Devise
|
|
33
|
+
|
|
34
|
+
In your Devise initializer (`config/initializers/devise.rb`):
|
|
35
|
+
|
|
36
|
+
```ruby
|
|
37
|
+
config.omniauth :uber_eats_oauth2,
|
|
38
|
+
ENV['UBER_EATS_CLIENT_ID'],
|
|
39
|
+
ENV['UBER_EATS_CLIENT_SECRET']
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Standalone (Rack)
|
|
43
|
+
|
|
44
|
+
```ruby
|
|
45
|
+
use OmniAuth::Builder do
|
|
46
|
+
provider :uber_eats_oauth2,
|
|
47
|
+
ENV['UBER_EATS_CLIENT_ID'],
|
|
48
|
+
ENV['UBER_EATS_CLIENT_SECRET']
|
|
49
|
+
end
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Auth Hash Schema
|
|
53
|
+
|
|
54
|
+
After successful authentication, `request.env['omniauth.auth']` will contain:
|
|
55
|
+
|
|
56
|
+
```ruby
|
|
57
|
+
{
|
|
58
|
+
provider: 'uber_eats_oauth2',
|
|
59
|
+
uid: 'abc123', # store_id from Uber Eats
|
|
60
|
+
info: {
|
|
61
|
+
name: 'Pizza Palace', # store name
|
|
62
|
+
business_name: 'Pizza Palace',
|
|
63
|
+
email: nil # Uber Eats does not expose merchant email
|
|
64
|
+
},
|
|
65
|
+
credentials: {
|
|
66
|
+
token: 'ACCESS_TOKEN',
|
|
67
|
+
refresh_token: 'REFRESH_TOKEN',
|
|
68
|
+
expires_at: 1234567890,
|
|
69
|
+
expires: true
|
|
70
|
+
},
|
|
71
|
+
extra: {
|
|
72
|
+
raw_info: {
|
|
73
|
+
store_id: 'abc123',
|
|
74
|
+
store_name: 'Pizza Palace',
|
|
75
|
+
id: 'abc123',
|
|
76
|
+
status: 'ACTIVE'
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Configuration Options
|
|
83
|
+
|
|
84
|
+
| Option | Default | Description |
|
|
85
|
+
|--------|---------|-------------|
|
|
86
|
+
| `sandbox` | `false` | Reserved for future sandbox environment support |
|
|
87
|
+
|
|
88
|
+
## Callback URL
|
|
89
|
+
|
|
90
|
+
Uber Eats requires an **exact redirect URI match**. The strategy automatically strips query parameters from the callback URL before token exchange.
|
|
91
|
+
|
|
92
|
+
Register your callback URL in the [Uber Developer Dashboard](https://developer.uber.com/):
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
https://yourdomain.com/auth/uber_eats_oauth2/callback
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Token Refresh
|
|
99
|
+
|
|
100
|
+
Uber Eats access tokens are valid for **30 days** (2,592,000 seconds). To refresh:
|
|
101
|
+
|
|
102
|
+
```ruby
|
|
103
|
+
client = OAuth2::Client.new(
|
|
104
|
+
ENV['UBER_EATS_CLIENT_ID'],
|
|
105
|
+
ENV['UBER_EATS_CLIENT_SECRET'],
|
|
106
|
+
site: 'https://api.uber.com',
|
|
107
|
+
token_url: 'https://auth.uber.com/oauth/v2/token'
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
token = OAuth2::AccessToken.from_hash(client, {
|
|
111
|
+
access_token: stored_token,
|
|
112
|
+
refresh_token: stored_refresh_token
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
new_token = token.refresh!
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Scopes
|
|
119
|
+
|
|
120
|
+
The default scope is `eats.pos_provisioning` (authorization_code flow for merchant connection). Other available scopes:
|
|
121
|
+
|
|
122
|
+
- `eats.store` - Store data access
|
|
123
|
+
- `eats.order` - Order data access
|
|
124
|
+
- `eats.report` - Report data access
|
|
125
|
+
|
|
126
|
+
## Development
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
git clone https://github.com/dan1d/omniauth-uber-eats-oauth2.git
|
|
130
|
+
cd omniauth-uber-eats-oauth2
|
|
131
|
+
bundle install
|
|
132
|
+
bundle exec rspec # Run tests (100% line + branch coverage required)
|
|
133
|
+
bundle exec rubocop # Run linter (0 offenses required)
|
|
134
|
+
bundle exec rake # Run both
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## License
|
|
138
|
+
|
|
139
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'omniauth-oauth2'
|
|
4
|
+
|
|
5
|
+
module OmniAuth
|
|
6
|
+
module Strategies
|
|
7
|
+
# OmniAuth strategy for Uber Eats OAuth2 (Delivery provider).
|
|
8
|
+
#
|
|
9
|
+
# Uber Eats uses OAuth2 with two grant types:
|
|
10
|
+
# - authorization_code: for store provisioning (eats.pos_provisioning scope)
|
|
11
|
+
# - client_credentials: for store/order/report data (eats.store, eats.order, eats.report)
|
|
12
|
+
#
|
|
13
|
+
# We use authorization_code flow for initial merchant connection, then
|
|
14
|
+
# client_credentials for ongoing API access (report data).
|
|
15
|
+
#
|
|
16
|
+
# Access tokens are valid for 30 days (2,592,000 seconds).
|
|
17
|
+
# Rate limit: 100 token requests per hour.
|
|
18
|
+
#
|
|
19
|
+
# API docs: https://developer.uber.com/docs/eats/guides/authentication
|
|
20
|
+
#
|
|
21
|
+
# @example Basic usage
|
|
22
|
+
# provider :uber_eats_oauth2, ENV['UBER_EATS_CLIENT_ID'], ENV['UBER_EATS_CLIENT_SECRET']
|
|
23
|
+
#
|
|
24
|
+
class UberEatsOauth2 < OmniAuth::Strategies::OAuth2
|
|
25
|
+
option :name, 'uber_eats_oauth2'
|
|
26
|
+
|
|
27
|
+
option :client_options, {
|
|
28
|
+
site: 'https://api.uber.com',
|
|
29
|
+
authorize_url: 'https://auth.uber.com/oauth/v2/authorize',
|
|
30
|
+
token_url: 'https://auth.uber.com/oauth/v2/token',
|
|
31
|
+
auth_scheme: :request_body
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
option :authorize_params, {
|
|
35
|
+
response_type: 'code',
|
|
36
|
+
scope: 'eats.pos_provisioning'
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
option :sandbox, false
|
|
40
|
+
|
|
41
|
+
# Override to strip query params from callback_url for redirect_uri matching.
|
|
42
|
+
def build_access_token
|
|
43
|
+
redirect_uri = callback_url.sub(/\?.*/, '')
|
|
44
|
+
log(:info, "Token exchange — site: #{client.site}, redirect_uri: #{redirect_uri}")
|
|
45
|
+
verifier = request.params['code']
|
|
46
|
+
client.auth_code.get_token(
|
|
47
|
+
verifier,
|
|
48
|
+
{ redirect_uri: redirect_uri }.merge(token_params.to_hash(symbolize_keys: true)),
|
|
49
|
+
deep_symbolize(options.auth_token_params)
|
|
50
|
+
)
|
|
51
|
+
rescue ::OAuth2::Error => e
|
|
52
|
+
log(:error, "Token exchange FAILED: status=#{e.response&.status} body=#{e.response&.body}")
|
|
53
|
+
raise
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
uid { raw_info['store_id'] || raw_info['id'] }
|
|
57
|
+
|
|
58
|
+
info do
|
|
59
|
+
{
|
|
60
|
+
name: raw_info['store_name'],
|
|
61
|
+
business_name: raw_info['store_name'],
|
|
62
|
+
email: nil # Uber Eats doesn't provide merchant email via API
|
|
63
|
+
}
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
extra do
|
|
67
|
+
{ raw_info: raw_info }
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def raw_info
|
|
71
|
+
@raw_info ||= fetch_store_info
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
private
|
|
75
|
+
|
|
76
|
+
def fetch_store_info
|
|
77
|
+
response = access_token.get('/v1/eats/stores')
|
|
78
|
+
parsed = response.parsed
|
|
79
|
+
stores = parsed['stores'] || []
|
|
80
|
+
store = stores.first
|
|
81
|
+
|
|
82
|
+
if store
|
|
83
|
+
{
|
|
84
|
+
'store_id' => store['store_id'],
|
|
85
|
+
'store_name' => store['name'] || store['store_name'],
|
|
86
|
+
'id' => store['store_id'],
|
|
87
|
+
'status' => store['status']
|
|
88
|
+
}
|
|
89
|
+
else
|
|
90
|
+
{ 'store_id' => nil }
|
|
91
|
+
end
|
|
92
|
+
rescue StandardError => e
|
|
93
|
+
log(:warn, "Failed to fetch store info: #{e.message}")
|
|
94
|
+
{ 'store_id' => nil }
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def log(level, message)
|
|
98
|
+
return unless defined?(OmniAuth.logger) && OmniAuth.logger
|
|
99
|
+
|
|
100
|
+
OmniAuth.logger.send(level, "[UberEatsOauth2] #{message}")
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: omniauth-uber-eats-oauth2
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- dan1d
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: omniauth-oauth2
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '1.8'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - "~>"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '1.8'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: rspec
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - "~>"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '3.12'
|
|
33
|
+
type: :development
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - "~>"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '3.12'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: rubocop
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - "~>"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '1.75'
|
|
47
|
+
type: :development
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - "~>"
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '1.75'
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: rubocop-rspec
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - "~>"
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '3.5'
|
|
61
|
+
type: :development
|
|
62
|
+
prerelease: false
|
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - "~>"
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '3.5'
|
|
68
|
+
- !ruby/object:Gem::Dependency
|
|
69
|
+
name: simplecov
|
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - "~>"
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '0.22'
|
|
75
|
+
type: :development
|
|
76
|
+
prerelease: false
|
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
78
|
+
requirements:
|
|
79
|
+
- - "~>"
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: '0.22'
|
|
82
|
+
- !ruby/object:Gem::Dependency
|
|
83
|
+
name: simplecov-json
|
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - "~>"
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: '0.2'
|
|
89
|
+
type: :development
|
|
90
|
+
prerelease: false
|
|
91
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
92
|
+
requirements:
|
|
93
|
+
- - "~>"
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: '0.2'
|
|
96
|
+
- !ruby/object:Gem::Dependency
|
|
97
|
+
name: webmock
|
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
|
99
|
+
requirements:
|
|
100
|
+
- - "~>"
|
|
101
|
+
- !ruby/object:Gem::Version
|
|
102
|
+
version: '3.18'
|
|
103
|
+
type: :development
|
|
104
|
+
prerelease: false
|
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
106
|
+
requirements:
|
|
107
|
+
- - "~>"
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: '3.18'
|
|
110
|
+
description: An OmniAuth strategy for authenticating with Uber Eats using OAuth 2.0.
|
|
111
|
+
Supports store provisioning via the eats.pos_provisioning scope.
|
|
112
|
+
email:
|
|
113
|
+
- dan1d@users.noreply.github.com
|
|
114
|
+
executables: []
|
|
115
|
+
extensions: []
|
|
116
|
+
extra_rdoc_files: []
|
|
117
|
+
files:
|
|
118
|
+
- CHANGELOG.md
|
|
119
|
+
- LICENSE.txt
|
|
120
|
+
- README.md
|
|
121
|
+
- lib/omniauth-uber-eats-oauth2.rb
|
|
122
|
+
- lib/omniauth/strategies/uber_eats_oauth2.rb
|
|
123
|
+
- lib/omniauth/uber_eats_oauth2/version.rb
|
|
124
|
+
homepage: https://github.com/dan1d/omniauth-uber-eats-oauth2
|
|
125
|
+
licenses:
|
|
126
|
+
- MIT
|
|
127
|
+
metadata:
|
|
128
|
+
homepage_uri: https://github.com/dan1d/omniauth-uber-eats-oauth2
|
|
129
|
+
source_code_uri: https://github.com/dan1d/omniauth-uber-eats-oauth2
|
|
130
|
+
changelog_uri: https://github.com/dan1d/omniauth-uber-eats-oauth2/blob/main/CHANGELOG.md
|
|
131
|
+
rubygems_mfa_required: 'true'
|
|
132
|
+
rdoc_options: []
|
|
133
|
+
require_paths:
|
|
134
|
+
- lib
|
|
135
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
136
|
+
requirements:
|
|
137
|
+
- - ">="
|
|
138
|
+
- !ruby/object:Gem::Version
|
|
139
|
+
version: 3.0.0
|
|
140
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
|
+
requirements:
|
|
142
|
+
- - ">="
|
|
143
|
+
- !ruby/object:Gem::Version
|
|
144
|
+
version: '0'
|
|
145
|
+
requirements: []
|
|
146
|
+
rubygems_version: 3.6.9
|
|
147
|
+
specification_version: 4
|
|
148
|
+
summary: OmniAuth OAuth2 strategy for Uber Eats
|
|
149
|
+
test_files: []
|