简体   繁体   English

如何存储LinkedIn API AccessToken,以便每次使用LinkedIn API时都不必重新输入凭据?

[英]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的工作流程,例如:

  1. The Example asks for the 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 : 这个想法是:

  1. Get a token for a certain LinkedIn Account 获取某个LinkedIn帐户的令牌
  2. Store it in my app hardcoded, since this is the only account I will be using the retrieve information from LinkedIn. 将它存储在硬编码的应用程序中,因为这是我将使用LinkedIn检索信息的唯一帐户。
  3. Make API Calls using this token, everytime I need it 每当我需要时,使用此令牌进行API调用
  4. Parse the JSON/XML file 解析JSON / XML文件

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.

相关问题 输入无效后,如何获取代码以重新进入循环 - How do I get my code to re-enter the loop after an invalid input 如何锁定并强制用户重新输入Windows密码? - How do I lock and force the user to re-enter one's windows password? 我有一个API,但我不知道如何获取数据 - I have an API, and I don't know how to get the data LinkedIn V2 API权限似乎不起作用 - LinkedIn V2 API permission's don't seem to be working 如何通过LinkedIn API使用其他人的电子邮件ID发送邀请? - How can I send an invitation using another person's email ID with the LinkedIn API? 我是否必须处理我不使用的退回物品? - Do I have to dispose of returned objects that I don't use? 当我尝试使用DotNetOpenAuth访问其API时,从LinkedIn获得HTTP 400错误 - Getting a HTTP 400 Error from LinkedIn when I try to access its API with DotNetOpenAuth 如何将 C# REST API HttpClient 用于基本 Z099FB995346F31C749F6E40C3FZ 身份验证和默认 ADF 凭据? - How do I use C# REST API HttpClient for both Basic header authentication and for default AD credentials? 如何从我没有API的WinForm应用程序中获取RadioButton的值? - How to get a value of a RadioButton from a WinForm application that I don't have an API for? 如何将凭据传递到计算机,以便可以在计算机上使用Microsoft.Win32.RegistryKey.OpenRemoteBaseKey()? - How do I pass credentials to a machine so I can use Microsoft.Win32.RegistryKey.OpenRemoteBaseKey() on it?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM