LinkedIn API: How to refresh access tokens from a console application

这一生的挚爱 提交于 2019-12-24 09:28:19

问题


In LinkedIn API, the access tokens will be expired after 60 days, I want to refresh them in 60 days before they are expired in a console application. I viewed this document: https://developer.linkedin.com/blog/tips-and-tricks-refreshing-access-token, and I also viewed many posts in this forum, but it looks like the refresh flow is still now clear for me.

Please note that: I need to refresh access tokens from a console application - it is not a website, it is a tool running in backend, it has no cookies and cannot open web page to ask user to login.

And if there are some sample code (not for website) that should be better, for example: C# or Java code.


回答1:


You can use curl to accomplish this. For whatever programming language you use, there should be a relevant curl library.

The way this works is as follows:

  1. You send a POST request to https://api.linkedin.com/uas/oauth/requestToken
  2. You receive back a request token. Use that token in place of XXX in the following call: https//www.linkedin.com/uas/oauth/authenticate?oauth_token=XXX
  3. You will receive the response you need, which includes the access token, which you need to save. It will not expire for the next 60 days.

If you could elaborate on the issues you're having, that would certainly help.

I see what you mean now. Linkedin doesn't allow you and will never allow you to do this. The reason access tokens expire is in order to add an extra layer of privacy protection for users. Linkedin would never want you to access user data if the user's aren't actively using your application. Of course, you might have a situation where no action is required on their part, that's the only drawback. Therefore, you would need to give them a reason to visit your application at least once in each token's lifetime.

I hope this helps.



来源:https://stackoverflow.com/questions/13411938/linkedin-api-how-to-refresh-access-tokens-from-a-console-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!