The /oauth2/revoke endpoint throws {"__type":"UnknownOperationException"}

0

Im trying to invalidate refresh token using The /oauth2/revoke endpoint. But the /oauth2/revoke endpoint throws {"__type":"UnknownOperationException"} https://docs.aws.amazon.com/cognito/latest/developerguide/revocation-endpoint.html

var axios = require("axios").default;

var options = { method: 'POST', url: 'https://{yourDomain}/oauth/revoke', headers: {'content-type': 'application/json'}, data: { client_id: '{yourClientId}', token: '{yourRefreshToken}' } };

axios.request(options).then(function (response) { console.log(response.data); }).catch(function (error) { console.error(error); });

Minaxi
질문됨 한 달 전289회 조회
2개 답변
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:

profile picture
전문가
답변함 한 달 전
profile picture
전문가
검토됨 한 달 전
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
profile picture
전문가
답변함 한 달 전
  • 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?

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠