【发布时间】:2021-09-23 06:19:39
【问题描述】:
我正在尝试在 jsp 加载时点击 cognito 授权 URL。当 JSP 被调用时,我在我的 jsp 中调用了一个 java 方法。以下是代码sn-p:
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.getParameter("code"); 中获取它,但没有成功。
如何获取代码?它作为查询参数附加到 url。
用户 [14/Jul/2021:15:35:43 -0400] “获取 /app?code=fdsfs-fsd-4324-4324-fdsfsdfjh5u34 HTTP/1.1" 302 - 6553
【问题讨论】:
标签: jsp servlets oauth-2.0 oauth amazon-cognito