2 Answers
- Newest
- Most votes
- Most comments
1
The data payload should be URL-encoded, not JSON. You can use the querystring module to encode your data:
var axios = require("axios").default; var querystring = require('querystring'); var data = querystring.stringify({ client_id: '{yourClientId}', token: '{yourRefreshToken}', token_type_hint: 'refresh_token' // Optional, but recommended }); var options = { method: 'POST', url: 'https://{yourDomain}/oauth2/revoke', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, data: data }; axios.request(options).then(function (response) { console.log(response.data); }).catch(function (error) { console.error(error); });
Key Source:
0
Hi,
The request content type is not correct, you must use application/x-www-form-urlencoded
instead of application/json
.
Take a look at the following example from the AWS documentation:
POST /oauth2/revoke HTTP/1.1
Host: https://mydomain.auth.us-east-1.amazoncognito.com
Accept: application/json
Content-Type: application/x-www-form-urlencoded
token=2YotnFZFEjr1zCsicMWpAA&
client_id=djc98u3jiedmi283eu928
Relevant content
- asked 6 months ago
- asked 3 years ago
- AWS OFFICIALUpdated 6 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 7 months ago
this gives me response {"code":"BadRequest","message":"The server did not understand the operation that was requested.","type":"client"}
Have you updated the body parameters to send them according to the new Content-Type and not as JSON?