ultracart_api 4.1.163 → 4.1.166
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 +4 -4
- data/LICENSE +201 -201
- data/README.md +611 -602
- data/docs/AffiliateApi.md +455 -455
- data/docs/AutoOrderApi.md +1694 -1694
- data/docs/BulkApi.md +335 -335
- data/docs/ChannelPartnerApi.md +1678 -1678
- data/docs/CheckoutApi.md +1622 -1622
- data/docs/ConversationApi.md +7867 -7867
- data/docs/ConversationEmbedApi.md +226 -226
- data/docs/CouponApi.md +1522 -1522
- data/docs/CustomerApi.md +2849 -2849
- data/docs/DatawarehouseApi.md +1637 -1637
- data/docs/EmailCommseqEmailReviewStatus.md +32 -0
- data/docs/EmailCommseqEmailReviewStatusResponse.md +26 -0
- data/docs/EmailCommseqEmailReviewStatusesRequest.md +18 -0
- data/docs/EmailCommseqEmailReviewStatusesResponse.md +26 -0
- data/docs/FraudApi.md +332 -332
- data/docs/FulfillmentApi.md +567 -567
- data/docs/GiftCertificateApi.md +617 -617
- data/docs/IntegrationLogApi.md +290 -290
- data/docs/ItemApi.md +2502 -2502
- data/docs/OauthApi.md +311 -311
- data/docs/OrderApi.md +3396 -3396
- data/docs/SfvbApi.md +3883 -3883
- data/docs/SsoApi.md +223 -223
- data/docs/StorefrontApi.md +10143 -10035
- data/docs/TaxApi.md +1699 -1699
- data/docs/UserApi.md +606 -606
- data/docs/WebhookApi.md +840 -840
- data/docs/WorkflowApi.md +666 -666
- data/lib/ultracart_api/api/storefront_api.rb +143 -0
- data/lib/ultracart_api/models/email_commseq_email_review_status.rb +324 -0
- data/lib/ultracart_api/models/email_commseq_email_review_status_response.rb +256 -0
- data/lib/ultracart_api/models/email_commseq_email_review_statuses_request.rb +222 -0
- data/lib/ultracart_api/models/email_commseq_email_review_statuses_response.rb +258 -0
- data/lib/ultracart_api/version.rb +1 -1
- data/lib/ultracart_api.rb +4 -0
- metadata +11 -3
data/docs/OauthApi.md
CHANGED
|
@@ -1,311 +1,311 @@
|
|
|
1
|
-
# UltracartClient::OauthApi
|
|
2
|
-
|
|
3
|
-
All URIs are relative to *https://secure.ultracart.com/rest/v2*
|
|
4
|
-
|
|
5
|
-
| Method | HTTP request | Description |
|
|
6
|
-
| ------ | ------------ | ----------- |
|
|
7
|
-
| [**oauth_access_token**](OauthApi.md#oauth_access_token) | **POST** /oauth/token | Exchange authorization code for access token. |
|
|
8
|
-
| [**oauth_device_authorize**](OauthApi.md#oauth_device_authorize) | **POST** /oauth/device/authorize | Initiate a device authorization flow. |
|
|
9
|
-
| [**oauth_me**](OauthApi.md#oauth_me) | **GET** /oauth/me | Identify the merchant account this access token belongs to. |
|
|
10
|
-
| [**oauth_revoke**](OauthApi.md#oauth_revoke) | **POST** /oauth/revoke | Revoke this OAuth application. |
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
## oauth_access_token
|
|
14
|
-
|
|
15
|
-
> <OauthTokenResponse> oauth_access_token(client_id, grant_type, opts)
|
|
16
|
-
|
|
17
|
-
Exchange authorization code for access token.
|
|
18
|
-
|
|
19
|
-
The final leg in the OAuth process which exchanges the specified access token for the access code needed to make API calls.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
### Examples
|
|
23
|
-
|
|
24
|
-
```ruby
|
|
25
|
-
require 'ultracart_api'
|
|
26
|
-
require_relative '../constants'
|
|
27
|
-
|
|
28
|
-
=begin
|
|
29
|
-
|
|
30
|
-
The first step in implementing an OAuth authorization to your UltraCart Developer Application is
|
|
31
|
-
creating a Client ID and Secret. See the following doc for instructions on doing so:
|
|
32
|
-
https://ultracart.atlassian.net/wiki/spaces/ucdoc/pages/3488907265/Developer+Applications+-+Creating+a+Client+ID+and+Secret+for+an+OAuth+Application
|
|
33
|
-
|
|
34
|
-
The second step is to construct an authorize url for your customers to follow and authorize your application.
|
|
35
|
-
See the oauthAuthorize.rb for an example on constructing that url.
|
|
36
|
-
|
|
37
|
-
This method, OAuth.oauth_access_token() will be called from within your redirect script, i.e. that web page the
|
|
38
|
-
customer is redirected to by UltraCart after successfully authorizing your application.
|
|
39
|
-
|
|
40
|
-
This example illustrates how to retrieve the code parameter and exchange it for an access_token and refresh_token.
|
|
41
|
-
|
|
42
|
-
Once you have your Client ID and Secret created, our OAuth security follows the industry standards.
|
|
43
|
-
1. Construct an authorize url for your customers.
|
|
44
|
-
2. Your customers will follow the link and authorize your application.
|
|
45
|
-
3. Store their oauth credentials as best fits your application.
|
|
46
|
-
|
|
47
|
-
Parameters this script should expect:
|
|
48
|
-
code -> used to exchange for an access token
|
|
49
|
-
state -> whatever you passed in your authorize url
|
|
50
|
-
error -> if you have a problem with your application configure. Possible values are:
|
|
51
|
-
invalid_request -> your authorize url has expired
|
|
52
|
-
access_denied -> user said 'no' and did not grant access.
|
|
53
|
-
|
|
54
|
-
Parameters you will use to retrieve a token:
|
|
55
|
-
code -> the value provided as a query parameter from UltraCart, required if grant_type is 'authorization_code'
|
|
56
|
-
client_id -> your client id (see doc link at top of this file)
|
|
57
|
-
grant_type -> 'authorization_code' or 'refresh_token'
|
|
58
|
-
redirect_url -> The URI that you redirect the browser to start the authorization process
|
|
59
|
-
refresh_token -> if grant_type = 'refresh_token', you have to provide the refresh token. makes sense, yes?
|
|
60
|
-
|
|
61
|
-
See OauthTokenResponse for fields that are returned from this call.
|
|
62
|
-
All SDKs have the same field names with slight differences in capitalization and underscores.
|
|
63
|
-
https://github.com/UltraCart/rest_api_v2_sdk_csharp/blob/master/src/com.ultracart.admin.v2/Model/OauthTokenResponse.cs
|
|
64
|
-
|
|
65
|
-
=end
|
|
66
|
-
|
|
67
|
-
client_id = "5e31ce86e17f02015a35257c47151544" # this is given to you when you create your application (see the doc link above)
|
|
68
|
-
grant_type = "authorization_code"
|
|
69
|
-
redirect_url = "https://www.mywebsite.com/oauth/redirect_here.php"
|
|
70
|
-
state = "denmark" # this is whatever you used when you created your authorize url (see oauthAuthorize.rb)
|
|
71
|
-
|
|
72
|
-
code = params['code'] # Assuming this is running in a web framework that provides params
|
|
73
|
-
refresh_token = nil
|
|
74
|
-
|
|
75
|
-
oauth_api = UltracartClient::OauthApi.new_using_api_key(Constants::API_KEY)
|
|
76
|
-
api_response = oauth_api.oauth_access_token(client_id, grant_type, code, redirect_url, refresh_token)
|
|
77
|
-
|
|
78
|
-
# api_response is an OauthTokenResponse object.
|
|
79
|
-
puts api_response.inspect
|
|
80
|
-
refresh_token = api_response.refresh_token
|
|
81
|
-
expires_in = api_response.expires_in
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
#### Using the oauth_access_token_with_http_info variant
|
|
86
|
-
|
|
87
|
-
This returns an Array which contains the response data, status code and headers.
|
|
88
|
-
|
|
89
|
-
> <Array(<OauthTokenResponse>, Integer, Hash)> oauth_access_token_with_http_info(client_id, grant_type, opts)
|
|
90
|
-
|
|
91
|
-
```ruby
|
|
92
|
-
begin
|
|
93
|
-
# Exchange authorization code for access token.
|
|
94
|
-
data, status_code, headers = api_instance.oauth_access_token_with_http_info(client_id, grant_type, opts)
|
|
95
|
-
p status_code # => 2xx
|
|
96
|
-
p headers # => { ... }
|
|
97
|
-
p data # => <OauthTokenResponse>
|
|
98
|
-
rescue UltracartClient::ApiError => e
|
|
99
|
-
puts "Error when calling OauthApi->oauth_access_token_with_http_info: #{e}"
|
|
100
|
-
end
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
### Parameters
|
|
104
|
-
|
|
105
|
-
| Name | Type | Description | Notes |
|
|
106
|
-
| ---- | ---- | ----------- | ----- |
|
|
107
|
-
| **client_id** | **String** | The OAuth application client_id. | |
|
|
108
|
-
| **grant_type** | **String** | Type of grant | |
|
|
109
|
-
| **code** | **String** | Authorization code received back from the browser redirect | [optional] |
|
|
110
|
-
| **redirect_uri** | **String** | The URI that you redirect the browser to start the authorization process | [optional] |
|
|
111
|
-
| **refresh_token** | **String** | The refresh token received during the original grant_type=authorization_code that can be used to return a new access token | [optional] |
|
|
112
|
-
| **device_code** | **String** | The device code received from /oauth/device/authorize | [optional] |
|
|
113
|
-
|
|
114
|
-
### Return type
|
|
115
|
-
|
|
116
|
-
[**OauthTokenResponse**](OauthTokenResponse.md)
|
|
117
|
-
|
|
118
|
-
### Authorization
|
|
119
|
-
|
|
120
|
-
[ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
|
|
121
|
-
|
|
122
|
-
### HTTP request headers
|
|
123
|
-
|
|
124
|
-
- **Content-Type**: application/x-www-form-urlencoded
|
|
125
|
-
- **Accept**: application/json
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
## oauth_device_authorize
|
|
129
|
-
|
|
130
|
-
> <OauthDeviceAuthorizationResponse> oauth_device_authorize(client_id, scope)
|
|
131
|
-
|
|
132
|
-
Initiate a device authorization flow.
|
|
133
|
-
|
|
134
|
-
Initiates the device authorization flow by returning a device code and user code. The device displays the user code to the merchant, who visits the verification URI to approve the request. RFC 8628.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
### Examples
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
(No example for this operation).
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
#### Using the oauth_device_authorize_with_http_info variant
|
|
144
|
-
|
|
145
|
-
This returns an Array which contains the response data, status code and headers.
|
|
146
|
-
|
|
147
|
-
> <Array(<OauthDeviceAuthorizationResponse>, Integer, Hash)> oauth_device_authorize_with_http_info(client_id, scope)
|
|
148
|
-
|
|
149
|
-
```ruby
|
|
150
|
-
begin
|
|
151
|
-
# Initiate a device authorization flow.
|
|
152
|
-
data, status_code, headers = api_instance.oauth_device_authorize_with_http_info(client_id, scope)
|
|
153
|
-
p status_code # => 2xx
|
|
154
|
-
p headers # => { ... }
|
|
155
|
-
p data # => <OauthDeviceAuthorizationResponse>
|
|
156
|
-
rescue UltracartClient::ApiError => e
|
|
157
|
-
puts "Error when calling OauthApi->oauth_device_authorize_with_http_info: #{e}"
|
|
158
|
-
end
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
### Parameters
|
|
162
|
-
|
|
163
|
-
| Name | Type | Description | Notes |
|
|
164
|
-
| ---- | ---- | ----------- | ----- |
|
|
165
|
-
| **client_id** | **String** | The OAuth application client_id. | |
|
|
166
|
-
| **scope** | **String** | The application-level scope (e.g., crm, ultraship). | |
|
|
167
|
-
|
|
168
|
-
### Return type
|
|
169
|
-
|
|
170
|
-
[**OauthDeviceAuthorizationResponse**](OauthDeviceAuthorizationResponse.md)
|
|
171
|
-
|
|
172
|
-
### Authorization
|
|
173
|
-
|
|
174
|
-
[ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
|
|
175
|
-
|
|
176
|
-
### HTTP request headers
|
|
177
|
-
|
|
178
|
-
- **Content-Type**: application/x-www-form-urlencoded
|
|
179
|
-
- **Accept**: application/json
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
## oauth_me
|
|
183
|
-
|
|
184
|
-
> oauth_me
|
|
185
|
-
|
|
186
|
-
Identify the merchant account this access token belongs to.
|
|
187
|
-
|
|
188
|
-
Returns the UltraCart merchant account that authorized your application, along with the permissions that were granted. Call it immediately after exchanging your authorization code so you can display the connected account to your user and map it within your own system. Any OAuth access token may call this endpoint regardless of the permissions it holds. The granted permissions are the ones the merchant approved, which may be narrower than the permissions your application currently requests, because permissions are recorded when the merchant authorizes and do not change afterwards. If you add a permission to your application, already connected merchants keep the permissions they originally approved until they authorize again, so read this list rather than assuming your application's configured permissions.
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
### Examples
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
(No example for this operation).
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
#### Using the oauth_me_with_http_info variant
|
|
198
|
-
|
|
199
|
-
This returns an Array which contains the response data (`nil` in this case), status code and headers.
|
|
200
|
-
|
|
201
|
-
> <Array(nil, Integer, Hash)> oauth_me_with_http_info
|
|
202
|
-
|
|
203
|
-
```ruby
|
|
204
|
-
begin
|
|
205
|
-
# Identify the merchant account this access token belongs to.
|
|
206
|
-
data, status_code, headers = api_instance.oauth_me_with_http_info
|
|
207
|
-
p status_code # => 2xx
|
|
208
|
-
p headers # => { ... }
|
|
209
|
-
p data # => nil
|
|
210
|
-
rescue UltracartClient::ApiError => e
|
|
211
|
-
puts "Error when calling OauthApi->oauth_me_with_http_info: #{e}"
|
|
212
|
-
end
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
### Parameters
|
|
216
|
-
|
|
217
|
-
This endpoint does not need any parameter.
|
|
218
|
-
|
|
219
|
-
### Return type
|
|
220
|
-
|
|
221
|
-
nil (empty response body)
|
|
222
|
-
|
|
223
|
-
### Authorization
|
|
224
|
-
|
|
225
|
-
[ultraCartOauth](../README.md#ultraCartOauth)
|
|
226
|
-
|
|
227
|
-
### HTTP request headers
|
|
228
|
-
|
|
229
|
-
- **Content-Type**: Not defined
|
|
230
|
-
- **Accept**: application/json
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
## oauth_revoke
|
|
234
|
-
|
|
235
|
-
> <OauthRevokeSuccessResponse> oauth_revoke(client_id, token)
|
|
236
|
-
|
|
237
|
-
Revoke this OAuth application.
|
|
238
|
-
|
|
239
|
-
Revokes the OAuth application associated with the specified client_id and token.
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
### Examples
|
|
243
|
-
|
|
244
|
-
```ruby
|
|
245
|
-
require 'ultracart_api'
|
|
246
|
-
require_relative '../constants'
|
|
247
|
-
|
|
248
|
-
=begin
|
|
249
|
-
|
|
250
|
-
This is a last feature of the UltraCart OAuth Security Implementation.
|
|
251
|
-
oauthRevoke is used to kill an access token.
|
|
252
|
-
Call this method when a customer desires to terminate using your Developer Application.
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
The first step in implementing an OAuth authorization to your UltraCart Developer Application is
|
|
256
|
-
creating a Client ID and Secret. See the following doc for instructions on doing so:
|
|
257
|
-
https://ultracart.atlassian.net/wiki/spaces/ucdoc/pages/3488907265/Developer+Applications+-+Creating+a+Client+ID+and+Secret+for+an+OAuth+Application
|
|
258
|
-
|
|
259
|
-
=end
|
|
260
|
-
|
|
261
|
-
client_id = "5e31ce86e17f02015a35257c47151544" # this is given to you when you create your application (see the doc link above)
|
|
262
|
-
access_token = "123456789012345678901234567890" # this is stored by your application somewhere somehow.
|
|
263
|
-
|
|
264
|
-
oauth_api = UltracartClient::OauthApi.new_using_api_key(Constants::API_KEY)
|
|
265
|
-
api_response = oauth_api.oauth_revoke(client_id, access_token)
|
|
266
|
-
|
|
267
|
-
# api_response is an OauthRevokeSuccessResponse object.
|
|
268
|
-
puts api_response.inspect
|
|
269
|
-
successful = api_response.successful
|
|
270
|
-
message = api_response.message
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
#### Using the oauth_revoke_with_http_info variant
|
|
275
|
-
|
|
276
|
-
This returns an Array which contains the response data, status code and headers.
|
|
277
|
-
|
|
278
|
-
> <Array(<OauthRevokeSuccessResponse>, Integer, Hash)> oauth_revoke_with_http_info(client_id, token)
|
|
279
|
-
|
|
280
|
-
```ruby
|
|
281
|
-
begin
|
|
282
|
-
# Revoke this OAuth application.
|
|
283
|
-
data, status_code, headers = api_instance.oauth_revoke_with_http_info(client_id, token)
|
|
284
|
-
p status_code # => 2xx
|
|
285
|
-
p headers # => { ... }
|
|
286
|
-
p data # => <OauthRevokeSuccessResponse>
|
|
287
|
-
rescue UltracartClient::ApiError => e
|
|
288
|
-
puts "Error when calling OauthApi->oauth_revoke_with_http_info: #{e}"
|
|
289
|
-
end
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
### Parameters
|
|
293
|
-
|
|
294
|
-
| Name | Type | Description | Notes |
|
|
295
|
-
| ---- | ---- | ----------- | ----- |
|
|
296
|
-
| **client_id** | **String** | The OAuth application client_id. | |
|
|
297
|
-
| **token** | **String** | The OAuth access token that is to be revoked.. | |
|
|
298
|
-
|
|
299
|
-
### Return type
|
|
300
|
-
|
|
301
|
-
[**OauthRevokeSuccessResponse**](OauthRevokeSuccessResponse.md)
|
|
302
|
-
|
|
303
|
-
### Authorization
|
|
304
|
-
|
|
305
|
-
[ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
|
|
306
|
-
|
|
307
|
-
### HTTP request headers
|
|
308
|
-
|
|
309
|
-
- **Content-Type**: application/x-www-form-urlencoded
|
|
310
|
-
- **Accept**: application/json
|
|
311
|
-
|
|
1
|
+
# UltracartClient::OauthApi
|
|
2
|
+
|
|
3
|
+
All URIs are relative to *https://secure.ultracart.com/rest/v2*
|
|
4
|
+
|
|
5
|
+
| Method | HTTP request | Description |
|
|
6
|
+
| ------ | ------------ | ----------- |
|
|
7
|
+
| [**oauth_access_token**](OauthApi.md#oauth_access_token) | **POST** /oauth/token | Exchange authorization code for access token. |
|
|
8
|
+
| [**oauth_device_authorize**](OauthApi.md#oauth_device_authorize) | **POST** /oauth/device/authorize | Initiate a device authorization flow. |
|
|
9
|
+
| [**oauth_me**](OauthApi.md#oauth_me) | **GET** /oauth/me | Identify the merchant account this access token belongs to. |
|
|
10
|
+
| [**oauth_revoke**](OauthApi.md#oauth_revoke) | **POST** /oauth/revoke | Revoke this OAuth application. |
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## oauth_access_token
|
|
14
|
+
|
|
15
|
+
> <OauthTokenResponse> oauth_access_token(client_id, grant_type, opts)
|
|
16
|
+
|
|
17
|
+
Exchange authorization code for access token.
|
|
18
|
+
|
|
19
|
+
The final leg in the OAuth process which exchanges the specified access token for the access code needed to make API calls.
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Examples
|
|
23
|
+
|
|
24
|
+
```ruby
|
|
25
|
+
require 'ultracart_api'
|
|
26
|
+
require_relative '../constants'
|
|
27
|
+
|
|
28
|
+
=begin
|
|
29
|
+
|
|
30
|
+
The first step in implementing an OAuth authorization to your UltraCart Developer Application is
|
|
31
|
+
creating a Client ID and Secret. See the following doc for instructions on doing so:
|
|
32
|
+
https://ultracart.atlassian.net/wiki/spaces/ucdoc/pages/3488907265/Developer+Applications+-+Creating+a+Client+ID+and+Secret+for+an+OAuth+Application
|
|
33
|
+
|
|
34
|
+
The second step is to construct an authorize url for your customers to follow and authorize your application.
|
|
35
|
+
See the oauthAuthorize.rb for an example on constructing that url.
|
|
36
|
+
|
|
37
|
+
This method, OAuth.oauth_access_token() will be called from within your redirect script, i.e. that web page the
|
|
38
|
+
customer is redirected to by UltraCart after successfully authorizing your application.
|
|
39
|
+
|
|
40
|
+
This example illustrates how to retrieve the code parameter and exchange it for an access_token and refresh_token.
|
|
41
|
+
|
|
42
|
+
Once you have your Client ID and Secret created, our OAuth security follows the industry standards.
|
|
43
|
+
1. Construct an authorize url for your customers.
|
|
44
|
+
2. Your customers will follow the link and authorize your application.
|
|
45
|
+
3. Store their oauth credentials as best fits your application.
|
|
46
|
+
|
|
47
|
+
Parameters this script should expect:
|
|
48
|
+
code -> used to exchange for an access token
|
|
49
|
+
state -> whatever you passed in your authorize url
|
|
50
|
+
error -> if you have a problem with your application configure. Possible values are:
|
|
51
|
+
invalid_request -> your authorize url has expired
|
|
52
|
+
access_denied -> user said 'no' and did not grant access.
|
|
53
|
+
|
|
54
|
+
Parameters you will use to retrieve a token:
|
|
55
|
+
code -> the value provided as a query parameter from UltraCart, required if grant_type is 'authorization_code'
|
|
56
|
+
client_id -> your client id (see doc link at top of this file)
|
|
57
|
+
grant_type -> 'authorization_code' or 'refresh_token'
|
|
58
|
+
redirect_url -> The URI that you redirect the browser to start the authorization process
|
|
59
|
+
refresh_token -> if grant_type = 'refresh_token', you have to provide the refresh token. makes sense, yes?
|
|
60
|
+
|
|
61
|
+
See OauthTokenResponse for fields that are returned from this call.
|
|
62
|
+
All SDKs have the same field names with slight differences in capitalization and underscores.
|
|
63
|
+
https://github.com/UltraCart/rest_api_v2_sdk_csharp/blob/master/src/com.ultracart.admin.v2/Model/OauthTokenResponse.cs
|
|
64
|
+
|
|
65
|
+
=end
|
|
66
|
+
|
|
67
|
+
client_id = "5e31ce86e17f02015a35257c47151544" # this is given to you when you create your application (see the doc link above)
|
|
68
|
+
grant_type = "authorization_code"
|
|
69
|
+
redirect_url = "https://www.mywebsite.com/oauth/redirect_here.php"
|
|
70
|
+
state = "denmark" # this is whatever you used when you created your authorize url (see oauthAuthorize.rb)
|
|
71
|
+
|
|
72
|
+
code = params['code'] # Assuming this is running in a web framework that provides params
|
|
73
|
+
refresh_token = nil
|
|
74
|
+
|
|
75
|
+
oauth_api = UltracartClient::OauthApi.new_using_api_key(Constants::API_KEY)
|
|
76
|
+
api_response = oauth_api.oauth_access_token(client_id, grant_type, code, redirect_url, refresh_token)
|
|
77
|
+
|
|
78
|
+
# api_response is an OauthTokenResponse object.
|
|
79
|
+
puts api_response.inspect
|
|
80
|
+
refresh_token = api_response.refresh_token
|
|
81
|
+
expires_in = api_response.expires_in
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
#### Using the oauth_access_token_with_http_info variant
|
|
86
|
+
|
|
87
|
+
This returns an Array which contains the response data, status code and headers.
|
|
88
|
+
|
|
89
|
+
> <Array(<OauthTokenResponse>, Integer, Hash)> oauth_access_token_with_http_info(client_id, grant_type, opts)
|
|
90
|
+
|
|
91
|
+
```ruby
|
|
92
|
+
begin
|
|
93
|
+
# Exchange authorization code for access token.
|
|
94
|
+
data, status_code, headers = api_instance.oauth_access_token_with_http_info(client_id, grant_type, opts)
|
|
95
|
+
p status_code # => 2xx
|
|
96
|
+
p headers # => { ... }
|
|
97
|
+
p data # => <OauthTokenResponse>
|
|
98
|
+
rescue UltracartClient::ApiError => e
|
|
99
|
+
puts "Error when calling OauthApi->oauth_access_token_with_http_info: #{e}"
|
|
100
|
+
end
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Parameters
|
|
104
|
+
|
|
105
|
+
| Name | Type | Description | Notes |
|
|
106
|
+
| ---- | ---- | ----------- | ----- |
|
|
107
|
+
| **client_id** | **String** | The OAuth application client_id. | |
|
|
108
|
+
| **grant_type** | **String** | Type of grant | |
|
|
109
|
+
| **code** | **String** | Authorization code received back from the browser redirect | [optional] |
|
|
110
|
+
| **redirect_uri** | **String** | The URI that you redirect the browser to start the authorization process | [optional] |
|
|
111
|
+
| **refresh_token** | **String** | The refresh token received during the original grant_type=authorization_code that can be used to return a new access token | [optional] |
|
|
112
|
+
| **device_code** | **String** | The device code received from /oauth/device/authorize | [optional] |
|
|
113
|
+
|
|
114
|
+
### Return type
|
|
115
|
+
|
|
116
|
+
[**OauthTokenResponse**](OauthTokenResponse.md)
|
|
117
|
+
|
|
118
|
+
### Authorization
|
|
119
|
+
|
|
120
|
+
[ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
|
|
121
|
+
|
|
122
|
+
### HTTP request headers
|
|
123
|
+
|
|
124
|
+
- **Content-Type**: application/x-www-form-urlencoded
|
|
125
|
+
- **Accept**: application/json
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
## oauth_device_authorize
|
|
129
|
+
|
|
130
|
+
> <OauthDeviceAuthorizationResponse> oauth_device_authorize(client_id, scope)
|
|
131
|
+
|
|
132
|
+
Initiate a device authorization flow.
|
|
133
|
+
|
|
134
|
+
Initiates the device authorization flow by returning a device code and user code. The device displays the user code to the merchant, who visits the verification URI to approve the request. RFC 8628.
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
### Examples
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
(No example for this operation).
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
#### Using the oauth_device_authorize_with_http_info variant
|
|
144
|
+
|
|
145
|
+
This returns an Array which contains the response data, status code and headers.
|
|
146
|
+
|
|
147
|
+
> <Array(<OauthDeviceAuthorizationResponse>, Integer, Hash)> oauth_device_authorize_with_http_info(client_id, scope)
|
|
148
|
+
|
|
149
|
+
```ruby
|
|
150
|
+
begin
|
|
151
|
+
# Initiate a device authorization flow.
|
|
152
|
+
data, status_code, headers = api_instance.oauth_device_authorize_with_http_info(client_id, scope)
|
|
153
|
+
p status_code # => 2xx
|
|
154
|
+
p headers # => { ... }
|
|
155
|
+
p data # => <OauthDeviceAuthorizationResponse>
|
|
156
|
+
rescue UltracartClient::ApiError => e
|
|
157
|
+
puts "Error when calling OauthApi->oauth_device_authorize_with_http_info: #{e}"
|
|
158
|
+
end
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Parameters
|
|
162
|
+
|
|
163
|
+
| Name | Type | Description | Notes |
|
|
164
|
+
| ---- | ---- | ----------- | ----- |
|
|
165
|
+
| **client_id** | **String** | The OAuth application client_id. | |
|
|
166
|
+
| **scope** | **String** | The application-level scope (e.g., crm, ultraship). | |
|
|
167
|
+
|
|
168
|
+
### Return type
|
|
169
|
+
|
|
170
|
+
[**OauthDeviceAuthorizationResponse**](OauthDeviceAuthorizationResponse.md)
|
|
171
|
+
|
|
172
|
+
### Authorization
|
|
173
|
+
|
|
174
|
+
[ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
|
|
175
|
+
|
|
176
|
+
### HTTP request headers
|
|
177
|
+
|
|
178
|
+
- **Content-Type**: application/x-www-form-urlencoded
|
|
179
|
+
- **Accept**: application/json
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
## oauth_me
|
|
183
|
+
|
|
184
|
+
> oauth_me
|
|
185
|
+
|
|
186
|
+
Identify the merchant account this access token belongs to.
|
|
187
|
+
|
|
188
|
+
Returns the UltraCart merchant account that authorized your application, along with the permissions that were granted. Call it immediately after exchanging your authorization code so you can display the connected account to your user and map it within your own system. Any OAuth access token may call this endpoint regardless of the permissions it holds. The granted permissions are the ones the merchant approved, which may be narrower than the permissions your application currently requests, because permissions are recorded when the merchant authorizes and do not change afterwards. If you add a permission to your application, already connected merchants keep the permissions they originally approved until they authorize again, so read this list rather than assuming your application's configured permissions.
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
### Examples
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
(No example for this operation).
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
#### Using the oauth_me_with_http_info variant
|
|
198
|
+
|
|
199
|
+
This returns an Array which contains the response data (`nil` in this case), status code and headers.
|
|
200
|
+
|
|
201
|
+
> <Array(nil, Integer, Hash)> oauth_me_with_http_info
|
|
202
|
+
|
|
203
|
+
```ruby
|
|
204
|
+
begin
|
|
205
|
+
# Identify the merchant account this access token belongs to.
|
|
206
|
+
data, status_code, headers = api_instance.oauth_me_with_http_info
|
|
207
|
+
p status_code # => 2xx
|
|
208
|
+
p headers # => { ... }
|
|
209
|
+
p data # => nil
|
|
210
|
+
rescue UltracartClient::ApiError => e
|
|
211
|
+
puts "Error when calling OauthApi->oauth_me_with_http_info: #{e}"
|
|
212
|
+
end
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Parameters
|
|
216
|
+
|
|
217
|
+
This endpoint does not need any parameter.
|
|
218
|
+
|
|
219
|
+
### Return type
|
|
220
|
+
|
|
221
|
+
nil (empty response body)
|
|
222
|
+
|
|
223
|
+
### Authorization
|
|
224
|
+
|
|
225
|
+
[ultraCartOauth](../README.md#ultraCartOauth)
|
|
226
|
+
|
|
227
|
+
### HTTP request headers
|
|
228
|
+
|
|
229
|
+
- **Content-Type**: Not defined
|
|
230
|
+
- **Accept**: application/json
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
## oauth_revoke
|
|
234
|
+
|
|
235
|
+
> <OauthRevokeSuccessResponse> oauth_revoke(client_id, token)
|
|
236
|
+
|
|
237
|
+
Revoke this OAuth application.
|
|
238
|
+
|
|
239
|
+
Revokes the OAuth application associated with the specified client_id and token.
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
### Examples
|
|
243
|
+
|
|
244
|
+
```ruby
|
|
245
|
+
require 'ultracart_api'
|
|
246
|
+
require_relative '../constants'
|
|
247
|
+
|
|
248
|
+
=begin
|
|
249
|
+
|
|
250
|
+
This is a last feature of the UltraCart OAuth Security Implementation.
|
|
251
|
+
oauthRevoke is used to kill an access token.
|
|
252
|
+
Call this method when a customer desires to terminate using your Developer Application.
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
The first step in implementing an OAuth authorization to your UltraCart Developer Application is
|
|
256
|
+
creating a Client ID and Secret. See the following doc for instructions on doing so:
|
|
257
|
+
https://ultracart.atlassian.net/wiki/spaces/ucdoc/pages/3488907265/Developer+Applications+-+Creating+a+Client+ID+and+Secret+for+an+OAuth+Application
|
|
258
|
+
|
|
259
|
+
=end
|
|
260
|
+
|
|
261
|
+
client_id = "5e31ce86e17f02015a35257c47151544" # this is given to you when you create your application (see the doc link above)
|
|
262
|
+
access_token = "123456789012345678901234567890" # this is stored by your application somewhere somehow.
|
|
263
|
+
|
|
264
|
+
oauth_api = UltracartClient::OauthApi.new_using_api_key(Constants::API_KEY)
|
|
265
|
+
api_response = oauth_api.oauth_revoke(client_id, access_token)
|
|
266
|
+
|
|
267
|
+
# api_response is an OauthRevokeSuccessResponse object.
|
|
268
|
+
puts api_response.inspect
|
|
269
|
+
successful = api_response.successful
|
|
270
|
+
message = api_response.message
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
#### Using the oauth_revoke_with_http_info variant
|
|
275
|
+
|
|
276
|
+
This returns an Array which contains the response data, status code and headers.
|
|
277
|
+
|
|
278
|
+
> <Array(<OauthRevokeSuccessResponse>, Integer, Hash)> oauth_revoke_with_http_info(client_id, token)
|
|
279
|
+
|
|
280
|
+
```ruby
|
|
281
|
+
begin
|
|
282
|
+
# Revoke this OAuth application.
|
|
283
|
+
data, status_code, headers = api_instance.oauth_revoke_with_http_info(client_id, token)
|
|
284
|
+
p status_code # => 2xx
|
|
285
|
+
p headers # => { ... }
|
|
286
|
+
p data # => <OauthRevokeSuccessResponse>
|
|
287
|
+
rescue UltracartClient::ApiError => e
|
|
288
|
+
puts "Error when calling OauthApi->oauth_revoke_with_http_info: #{e}"
|
|
289
|
+
end
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### Parameters
|
|
293
|
+
|
|
294
|
+
| Name | Type | Description | Notes |
|
|
295
|
+
| ---- | ---- | ----------- | ----- |
|
|
296
|
+
| **client_id** | **String** | The OAuth application client_id. | |
|
|
297
|
+
| **token** | **String** | The OAuth access token that is to be revoked.. | |
|
|
298
|
+
|
|
299
|
+
### Return type
|
|
300
|
+
|
|
301
|
+
[**OauthRevokeSuccessResponse**](OauthRevokeSuccessResponse.md)
|
|
302
|
+
|
|
303
|
+
### Authorization
|
|
304
|
+
|
|
305
|
+
[ultraCartBrowserApiKey](../README.md#ultraCartBrowserApiKey), [ultraCartOauth](../README.md#ultraCartOauth), [ultraCartSimpleApiKey](../README.md#ultraCartSimpleApiKey)
|
|
306
|
+
|
|
307
|
+
### HTTP request headers
|
|
308
|
+
|
|
309
|
+
- **Content-Type**: application/x-www-form-urlencoded
|
|
310
|
+
- **Accept**: application/json
|
|
311
|
+
|