Software / code / prosody-modules
Comparison
mod_rest/README.markdown @ 4068:504a0cd5f883
mod_rest/README: Mention OAuth
mod_http_oauth2 needs docs too
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Mon, 20 Jul 2020 21:55:07 +0200 |
| parent | 4067:5790c3cf615b |
| child | 4069:b89f381abaa9 |
comparison
equal
deleted
inserted
replaced
| 4067:5790c3cf615b | 4068:504a0cd5f883 |
|---|---|
| 21 | 21 |
| 22 ## As a Component | 22 ## As a Component |
| 23 | 23 |
| 24 ``` {.lua} | 24 ``` {.lua} |
| 25 Component "rest.example.net" "rest" | 25 Component "rest.example.net" "rest" |
| 26 rest_credentials = "Bearer dmVyeSBzZWNyZXQgdG9rZW4K" | 26 component_secret = "dmVyeSBzZWNyZXQgdG9rZW4K" |
| 27 ``` | 27 modules_enabled = {"http_oauth2"} |
| 28 ``` | |
| 29 | |
| 30 ## OAuth2 | |
| 31 | |
| 32 [mod_http_oauth2] can be used to grant bearer tokens which are | |
| 33 accepted by mod_rest. | |
| 28 | 34 |
| 29 ## Sending stanzas | 35 ## Sending stanzas |
| 30 | 36 |
| 31 The API endpoint becomes available at the path `/rest`, so the full URL | 37 The API endpoint becomes available at the path `/rest`, so the full URL |
| 32 will be something like `https://your-prosody.example:5281/rest`. | 38 will be something like `https://your-prosody.example:5281/rest`. |
| 33 | 39 |
| 34 To try it, simply `curl` an XML stanza payload: | 40 To try it, simply `curl` an XML stanza payload: |
| 35 | 41 |
| 36 ``` {.sh} | 42 ``` {.sh} |
| 37 curl https://prosody.example:5281/rest \ | 43 curl https://prosody.example:5281/rest \ |
| 38 --oauth2-bearer dmVyeSBzZWNyZXQgdG9rZW4K \ | 44 --user username \ |
| 39 -H 'Content-Type: application/xmpp+xml' \ | 45 -H 'Content-Type: application/xmpp+xml' \ |
| 40 --data-binary '<message type="chat" to="user@example.org"> | 46 --data-binary '<message type="chat" to="user@example.org"> |
| 41 <body>Hello!</body> | 47 <body>Hello!</body> |
| 42 </body>' | 48 </body>' |
| 43 ``` | 49 ``` |