[英]How do I store the LinkedIn API AccessToken so I don't have to re-enter credentials every time I use the LinkedIn API?
I am writing an app to mine information from LinkedIn . 我正在编写一个应用程序来从LinkedIn获取信息。 I've only found one code sample thus far on oAuth.
到目前为止,我只在oAuth上找到了一个代码示例 。 I'm having trouble understanding the workflow of oAuth, for example:
我无法理解oAuth的工作流程,例如:
Username/Password
combination to log into LinkedIn and return a token, but in my case, I will always use the same LinkedIn Account. Username/Password
组合登录LinkedIn并返回令牌,但在我的情况下,我将始终使用相同的LinkedIn帐户。 Since I'm always going to be using the same user to access the LinkedIn API, is there a way to do it so I don't have to re-enter the user name and password for every access request? 由于我总是会使用相同的用户来访问LinkedIn API,有没有办法这样做,所以我不必为每个访问请求重新输入用户名和密码? The facebook API allows me to set the Token to not expire, thereby allowing me to save this token as an
Attribute
inside my application). facebook API允许我将令牌设置为不过期,从而允许我将此令牌保存为我的应用程序中的
Attribute
)。
The idea is : 这个想法是:
How do I do this in C#? 我如何在C#中执行此操作?
You first need to determine the member token, and the corresponding OAuth token -- you could do this as a one off, and LinkedIn have some quite good documentation about authorizing (along with links to tools to verify, and to libraries that you can use to simplyify matters) 您首先需要确定成员令牌和相应的OAuth令牌 - 您可以一次性执行此操作,LinkedIn有一些关于授权的相当好的文档 (以及要验证的工具的链接,以及您可以使用的库)简化事项)
Once you have those, it's just a case of storing them "somewhere safe" - there is even a clause in the LinkedIn APIs Terms of Use that permits storage: 一旦你拥有了它们,它只是将它们存储在“安全的地方”的情况下 - 在LinkedIn API使用条款中甚至有一个允许存储的条款 :
You may store the Member Token and the OAuth Token until the earlier of:
您可以存储会员令牌和OAuth令牌,直到更早的时间:
- Your ceasing using the APIs;
您停止使用API;
- The LinkedIn user uninstalls your application or directs you to delete the user's information;
LinkedIn用户卸载您的应用程序或指示您删除用户的信息; or,
要么,
- We terminate your use of them for breach of these Terms.
我们因违反这些条款而终止您使用它们。
Just to be exceptionally clear - what you need to store on your system is the OAuth access token for that member. 只是要非常清楚 - 您需要在系统上存储的是该成员的OAuth访问令牌。 So you will need to store that token along with the userID (just so you can remember who that token belongs to).
因此,您需要将该令牌与userID一起存储(这样您才能记住该令牌属于谁)。 That token, along with your API key and secret, should give you the ability to call the linkedin services.
该令牌以及您的API密钥和密钥应该使您能够调用linkedin服务。
There's a complete oAuth
ASP.NET + C# code example download available in the first post of the thread here: 在线程的第一篇文章中提供了完整的
oAuth
ASP.NET + C#代码示例下载:
You might also find the LinkedIn Toolkit to be of some help: 您可能还会发现LinkedIn Toolkit可以提供一些帮助:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.