我正在尝试在 jsp 加载时点击 cognito 授权 URL。当 JSP 被调用时,我在我的 jsp 中调用了一个 java 方法。以下是代码片段:
public static void getData(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setStatus(HttpServletResponse.SC_FOUND);
response.setHeader("Location",
"https://test.us-west-2.amazoncognito.com/oauth2/authorize?redirect_uri=https://test.com&client_id=123456789&response_type=code");
}
用户在点击 jsp 时成功被重定向。授权码code
附加到 url(我可以在 tomcat 日志中看到)。
我的方法中需要授权码。我已经尝试从 request 获取它request.getParameter("code");
,但这没有用。
如何获取代码?它作为查询参数附加到 url。
用户 [14/Jul/2021:15:35:43 -0400] “GET /app?code=fdsfs-fsd-4324-4324-fdsfsdfjh5u34 HTTP/1.1”302 - 6553