简体   繁体   English

使用LinkedIn的JavaScript获取AccessToken

[英]Get AccessToken with JavaScript from LinkedIn

I am developing a LinkedIn app with Javascript. 我正在用Javascript开发一个LinkedIn应用程序。 Is there a way to authenticate a user without requiring him to click on a button and get his access token which can be sended to my server with Javascript? 有没有办法验证用户,而不需要他点击按钮并获得可以使用Javascript发送到我的服务器的访问令牌?

I've only found this solution: https://gist.github.com/jsjohnst/efc88a38da25ff4e9283 but the shared secret can be viewed by all. 我只找到了这个解决方案: https//gist.github.com/jsjohnst/efc88a38da25ff4e9283但所有人都可以查看共享密码。

The first time the user logs in to your application, they will need to click the button. 用户首次登录您的应用程序时,需要单击该按钮。 This is impossible to bypass. 这是不可能绕过的。 If you add authorize: true to your Linkedin initialization code, they will not need to click the button for subsequent times. 如果您在Linkedin初始化代码中添加authorize: true ,则他们无需再次单击该按钮。 Code below: 代码如下:

<script src="http://platform.linkedin.com/in.js">
    api_key: YOUR_API_KEY
    authorize: true
</script>

As for sending the access token to your server, you will need to exchange the Javascript API tokens with a REST API OAuth token, as described in this document: http://developer.linkedin.com/documents/exchange-jsapi-tokens-rest-api-oauth-tokens 至于将访问令牌发送到您的服务器,您需要使用REST API OAuth令牌交换Javascript API令牌,如本文档中所述: http//developer.linkedin.com/documents/exchange-jsapi-tokens- REST的API,OAuth的令牌

I hope this helps. 我希望这有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM