如何将授权码从JSP传递到Servlet
我已经束手无策了,7个小时还在继续。
我是 FB 开发新手,在将授权代码从 JSP 传递到 Servlet 时遇到问题。
1.) 我使用社交插件登录我的 JSP,如下所示
<fb:login-button>Login with Facebook</fb:login-button>
这将用户登录并允许他们授予我的应用程序访问其个人信息的权限
2.) 登录并授权后成功后,用户通过下面的代码从 JSP 转发到我的 servlet
FB.Event.subscribe('auth.login', function (response) {
window.location = "testservlet";
});
3。)但是当我尝试在 Servlet 中获取授权代码(以便我可以获得 auth.token)时,“代码”为空,请参阅我用来检索下面的代码
String authCode = req.getParameter("code");
任何人都可以告诉我我做错了什么吗?我确信我错过了一些如此简单的事情..或者我正在尝试做超出必要的事情,提前致谢
I am at my wits end, 7 hours and counting.
I am new to FB development and am having an issue of passing the authorization code from my JSP to my Servlet.
1.) I use the social plugin for login in my JSP as shown below
<fb:login-button>Login with Facebook</fb:login-button>
This logs the user in and allows them to grant my app access to their personal information
2.) Once login and authorization are successful, the user is forwarded to my servlet from the JSP via the code below
FB.Event.subscribe('auth.login', function (response) {
window.location = "testservlet";
});
3.) But when I attempt to get the authorization code (so that I can get the auth. token) in my Servlet, the "code" is empty, see the code I am using to retrieve below
String authCode = req.getParameter("code");
Can anyone tell me what I am doing wrong? I am sure that I am missing something so simple..or am trying to do more than is necessary, thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我对 Facebook 开发不熟悉,但对于 servlet,window.location 通常来说不会带你到 servlet。
尝试使用jquery的ajax函数并传递一个“code”参数。做类似的事情:
I am not familiar with Facebook dev, but concerning servlets, window.location normally speaking will not take you to a servlet.
try using jquery's ajax function and pass a "code" parameter. Do something like :