通过 ASP.NET MVC 访问 LinkedIn cookie
我已经实现了新的 LinkedIn JavaScript API 来登录,并且正在尝试访问 cookie。我已经验证可以在 FireBug 的 Cookie 窗口中找到它:
linkedin_oauth_*API_KEY*
其中 API_KEY 是我的 API 字符串。但是,当我尝试在 ASP.NET MVC 代码中访问 cookie 时:
HttpCookie c = HttpContext.Current.Request.Cookies[cookieName];
它无法在 Cookie 中找到任何具有该名称的 cookie收藏。
在 FireBug 中,我看到 cookie 的属性是 Expires=Session 和 Security=Secure
有没有办法通过这些设置访问 cookie?
I've implemented the new LinkedIn JavaScript API to log in, and I'm trying to access a cookie. I've verified that it can be found in FireBug's Cookie window:
linkedin_oauth_*API_KEY*
where API_KEY is my API string.However, when I try to access the cookie in ASP.NET MVC code:
HttpCookie c = HttpContext.Current.Request.Cookies[cookieName];
It can't find any cookie with that name in the Cookies collection.
In FireBug, I see the cookie's properties are Expires=Session and Security=Secure
Is there a way to access cookies with these settings?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题是同源策略也适用于 cookie,因此您的服务器后端不会收到 cookie。
我猜您想使用 LinkedIn Js api 登录,将 oauth 令牌传递到服务器,然后在服务器端进行正常的 oauth 调用?对于这种情况,您需要将 oauth 令牌发送回服务器。有一篇很好的文章描述了这种情况: Exchange JSAPI Tokens for REST API OAuth Tokens
Problem is that the same origin policy applies also for the cookies, so your server backend doesn't receive the cookie.
I guess you want to sign-in with LinkedIn Js api, pass the oauth token to the server, and then make normal oauth calls on the server side? For this scenario, you need to send the oauth token back to the server. There is nice article describing this scenario: Exchange JSAPI Tokens for REST API OAuth Tokens
您只能通过 HTTPS 访问这些 cookie
You can only access those cookie through HTTPS