Mercurial > prosody-modules
comparison mod_rest/README.markdown @ 5179:5be04d1b16fb
mod_rest: Remove confusing oauth2 tokens from examples
Users were somehow confused into thinking that you should use the JID as
username, rather than the username.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 28 Feb 2023 18:15:20 +0100 |
parents | 51f7d72a56c2 |
children | d194d1012fd3 |
comparison
equal
deleted
inserted
replaced
5178:556bf57d6417 | 5179:5be04d1b16fb |
---|---|
36 modules_enabled = {"http_oauth2"} | 36 modules_enabled = {"http_oauth2"} |
37 ``` | 37 ``` |
38 | 38 |
39 ## OAuth2 | 39 ## OAuth2 |
40 | 40 |
41 [mod_http_oauth2] can be used to grant bearer tokens which are | 41 [mod_http_oauth2] can be used to grant bearer tokens which are accepted |
42 accepted by mod_rest. Tokens can be passed to `curl` like | 42 by mod_rest. Tokens can be passed to `curl` like `--oauth2-bearer |
43 `--oauth2-bearer dmVyeSBzZWNyZXQgdG9rZW4K` as in some examples below. | 43 dmVyeSBzZWNyZXQgdG9rZW4K` instead of using `--user`. |
44 | 44 |
45 ## Sending stanzas | 45 ## Sending stanzas |
46 | 46 |
47 The API endpoint becomes available at the path `/rest`, so the full URL | 47 The API endpoint becomes available at the path `/rest`, so the full URL |
48 will be something like `https://your-prosody.example:5281/rest`. | 48 will be something like `https://your-prosody.example:5281/rest`. |
60 | 60 |
61 or a JSON payload: | 61 or a JSON payload: |
62 | 62 |
63 ``` {.sh} | 63 ``` {.sh} |
64 curl https://prosody.example:5281/rest \ | 64 curl https://prosody.example:5281/rest \ |
65 --oauth2-bearer dmVyeSBzZWNyZXQgdG9rZW4K \ | 65 --user username \ |
66 -H 'Content-Type: application/json' \ | 66 -H 'Content-Type: application/json' \ |
67 --data-binary '{ | 67 --data-binary '{ |
68 "body" : "Hello!", | 68 "body" : "Hello!", |
69 "kind" : "message", | 69 "kind" : "message", |
70 "to" : "user@example.org", | 70 "to" : "user@example.org", |
79 New alternative format with the parameters `kind`, `type`, and `to` | 79 New alternative format with the parameters `kind`, `type`, and `to` |
80 embedded in the path: | 80 embedded in the path: |
81 | 81 |
82 ``` | 82 ``` |
83 curl https://prosody.example:5281/rest/message/chat/john@example.com \ | 83 curl https://prosody.example:5281/rest/message/chat/john@example.com \ |
84 --oauth2-bearer dmVyeSBzZWNyZXQgdG9rZW4K \ | 84 --user username \ |
85 -H 'Content-Type: text/plain' \ | 85 -H 'Content-Type: text/plain' \ |
86 --data-binary 'Hello John!' | 86 --data-binary 'Hello John!' |
87 ``` | 87 ``` |
88 | 88 |
89 ### Replies | 89 ### Replies |
91 A POST containing an `<iq>` stanza automatically wait for the reply, | 91 A POST containing an `<iq>` stanza automatically wait for the reply, |
92 long-polling style. | 92 long-polling style. |
93 | 93 |
94 ``` {.sh} | 94 ``` {.sh} |
95 curl https://prosody.example:5281/rest \ | 95 curl https://prosody.example:5281/rest \ |
96 --oauth2-bearer dmVyeSBzZWNyZXQgdG9rZW4K \ | 96 --user username \ |
97 -H 'Content-Type: application/xmpp+xml' \ | 97 -H 'Content-Type: application/xmpp+xml' \ |
98 --data-binary '<iq type="get" to="example.net"> | 98 --data-binary '<iq type="get" to="example.net"> |
99 <ping xmlns="urn:xmpp:ping"/> | 99 <ping xmlns="urn:xmpp:ping"/> |
100 </iq>' | 100 </iq>' |
101 ``` | 101 ``` |
109 | 109 |
110 A subset of IQ stanzas can be sent as simple GET requests | 110 A subset of IQ stanzas can be sent as simple GET requests |
111 | 111 |
112 ``` | 112 ``` |
113 curl https://prosody.example:5281/rest/version/example.com \ | 113 curl https://prosody.example:5281/rest/version/example.com \ |
114 --oauth2-bearer dmVyeSBzZWNyZXQgdG9rZW4K \ | 114 --user username \ |
115 -H 'Accept: application/json' | 115 -H 'Accept: application/json' |
116 ``` | 116 ``` |
117 | 117 |
118 The supported queries are | 118 The supported queries are |
119 | 119 |