POST запрос к ЕСИА

@RequestMapping(path  = "/code", method = {RequestMethod.GET})
ResponseEntity<Void> getCode() throws Exception {               
    return ResponseEntity.status(HttpStatus.FOUND)
            .location(URI.create("https://esia-portal1.test.gosuslugi.ru/aas/oauth2/ac?" +
                    "client_id=" + client_id + "&" +
                    "client_secret=" + client_secret + "&" +
                    "redirect_uri=http://localhost:8080/token&" +
                    "scope=" + scope + "&" +
                    "response_type=" + response_type + "&" +
                    "state=" + state + "&" +                        
                    "access_type=online&" +
                    "timestamp=" + time
            ))
            .build(); 
}

 

    @RequestMapping(path = "/token", method = { RequestMethod.POST })
    ResponseEntity<Void> getToken() throws Exception {
    
        return ResponseEntity.status(HttpStatus.OK)
                .location(URI.create("https://esia-portal1.test.gosuslugi.ru/aas/oauth2/te?" +
                        "client_id=" + client_id  + "&" +
                        "code=" + code + "&" +
                        "grant_type=authorization_code&" +
                        "client_secret=" + client_secret  + "&" +
                        "state=" + state  + "&" +
                        "redirect_uri=http://localhost:8080/personal&" +
                        "scope=" + scope + "&" +
                        "timestamp=" +time + "&" +
                        "token_type=Bearer"
                ))
                .build();    }

Прикручиваем авторизацию через ЕСИА. В методичке ЕСИА указано, что нужно выполнить два запроса к ЕСИА. Первый - GET которым производится перейход на ЕСИА, авторизация пользователя и возвращает кода авторизации на маршрут указанный в запросе. Второй - POST, который запрашивает у ЕСИА токен и возвращает его по маршруту указанному в запросе.

При выполнении второго запроса при переходе по маршруту /token получаю 405 Request method 'GET' not supported. Как выполнить POST запрос в таком случае?


Ответы (0 шт):