You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you are using Memphis **Open-Source** version, please make sure your 'REST gateway' component is exposed either through localhost or public IP.<br><br>
86
86
If you are using Memphis **Cloud**, it is already in.
87
87
88
-
### Authenticate
88
+
### 1. Create a JWT token
89
89
90
-
First, you have to authenticate to get a JWT token.\
91
-
The default expiration time is 15 minutes.
90
+
Please create a JWT token, which will be part of each produce/consume request. For authentication purposes.
92
91
93
-
#### Example:
92
+
* The generated JWT will encapsulate all the needed information for the broker to ensure the requester is authenticated to communicate with Memphis.
93
+
* JWT token (by design) has an expiration time. Token refreshment can take place progrematically, but as it is often used to integrate memphis with other systems which are not supporting JWT refreshment, a workaround to overcome it would be to set a very high value in the `token_expiry_in_minutes`.
94
+
* The default expiry time is 15 minutes.
94
95
95
-
* Cloud: Your REST GW URL can be found within a station->code examples
96
-
* OS: The REST GW will be deploy by default, and as with any other service, should be exposed based on your deployment type.
96
+
**Cloud (Using body params)**<br>
97
+
* Please replace the [Cloud], [Region], Username, Password, and Account ID with your parameters.
98
+
```bash
99
+
curl --location --request POST 'https://[Cloud]-[Region].restgw.cloud.memphis.dev/auth/authenticate' \
100
+
--header 'Content-Type: application/json' \
101
+
--data-raw '{
102
+
"username": "CLIENT_TYPE_USERNAME",
103
+
"password": "CLIENT_TYPE_PASSWORD",
104
+
"account_id": 123456789,
105
+
"token_expiry_in_minutes": 6000000,
106
+
"refresh_token_expiry_in_minutes": 100000
107
+
}'
108
+
```
109
+
110
+
**Cloud (Using query params)**<br>
111
+
* Please replace the [Cloud], [Region], Username, Password, and Account ID with your parameters.
112
+
```bash
113
+
curl --location --request POST 'https://[Cloud]-[Region].restgw.cloud.memphis.dev/auth/authenticate?accountId=123456789' \
114
+
--header 'Content-Type: application/json' \
115
+
--data-raw '{
116
+
"username": "CLIENT_TYPE_USERNAME",
117
+
"password": "CLIENT_TYPE_PASSWORD",
118
+
"token_expiry_in_minutes": 6000000,
119
+
"refresh_token_expiry_in_minutes": 100000
120
+
}'
121
+
```
97
122
123
+
**Open-source**
98
124
```bash
99
125
curl --location --request POST 'https://REST_GW_URL:4444/auth/authenticate' \
100
126
--header 'Content-Type: application/json' \
101
127
--data-raw '{
102
-
"username": "root",
103
-
// "connection_token": "memphis", // OS Only: In case the chosen auth method is connection_token
104
-
"password": "memphis, // OS + Cloud: client-type user password
105
-
"account_id": 123456789, // Cloud only, in case you don't have the ability to set this field as a body param you can add it as a query string param, for example: https://<REST-GW-ADDRESS>/auth/authenticate?accountId=123456789
Before the JWT token expires or after an authentication failure, you must call the refresh procedure and get a new token. The refresh JWT token is valid by default for 5 hours.
125
145
126
-
Before the JWT token expires, you must call the refresh token to get a new one, or after authentication failure.\
127
-
The refresh JWT is valid by default for 5 hours.
128
-
129
-
#### Example:
146
+
**Cloud**<br>
147
+
* Please replace the [Cloud], [Region], Username, and Password with your parameters.
148
+
```bash
149
+
curl --location --request POST 'https://[Cloud]-[Region].restgw.cloud.memphis.dev/auth/refreshToken' \
{"error":"Schema validation has failed: jsonschema: '' does not validate with file:///Users/user/memphisdev/memphis-rest-gateway/123#/required: missing properties: 'field1', 'field2', 'field3'","success":false}
185
225
```
186
226
187
-
### Produce a batch of messages 
188
-
189
-
Attach the JWT token to every request.\
190
-
JWT token as '`Bearer`' as a header.
227
+
<hr>
191
228
192
-
#### Supported content types:
229
+
### 3. Produce a batch of messages
230
+
**Supported content types:**
193
231
194
232
* application/json
195
233
196
-
#### Example:
234
+
**Cloud (Using body params)**
235
+
* Please replace the [Cloud], [Region], JWT token (right after `Bearer`) with your parameters.
236
+
197
237
198
238
```bash
199
-
curl --location --request POST 'rest_gateway:4444/stations/<station_name>/produce/batch' \
{"errors":["Schema validation has failed: jsonschema: '' does not validate with file:///Users/user/memphisdev/memphis-rest-gateway/123#/required: missing properties: 'field1'","Schema validation has failed: jsonschema: '' does not validate with file:///Users/user/memphisdev/memphis-rest-gateway/123#/required: missing properties: 'field1'"],"fail":2,"sent":1,"success":false}
219
286
```
220
-
### Consume a batch of messages 
221
287
222
-
Attach the JWT token to every request.\
223
-
JWT token as '`Bearer`' as a header.
288
+
<hr>
289
+
224
290
225
-
The messages are auto acknowledged by the rest gateway.
291
+
### 4. Consume a batch of messages 
226
292
227
-
#### Supported content types:
293
+
To avoid reading the same message twice and reduce network traffic for an ack per message, which is not scalable, messages are auto-acknowledged by the rest gateway.
294
+
295
+
**Supported content types:**
228
296
229
297
* application/json
230
298
231
-
#### Example:
299
+
**Cloud (Using body params)**
300
+
* Please replace the [Cloud], [Region], JWT token (right after `Bearer`) with your parameters.
301
+
302
+
303
+
```bash
304
+
curl --location --request POST 'https://[Cloud]-[Region].restgw.cloud.memphis.dev/stations/STATION_NAME/consume/batch' \
0 commit comments