简体   繁体   English

验证从linkedin Rest API获取的access token

[英]validate the access token obtained from the linkedin Rest API

I have a mobile application talking to a backend.我有一个与后端通信的移动应用程序。 I am providing login to the app through LinkedIn.我正在通过 LinkedIn 提供该应用程序的登录信息。 I checked the linkedIn api for oauth authentication and have followed the steps as given in this link Oauth LinkedIn .我检查了LinkedIn api 的 oauth 身份验证,并按照此链接Oauth LinkedIn 中给出的步骤进行了操作。

I am able to obtain the request token as per step 3. Now i am sending this request to my backend.我能够按照第 3 步获取请求令牌。现在我将此请求发送到我的后端。 In the backend i want to make sure that this request token is valid and has not expired.在后端,我想确保此请求令牌有效且未过期。

How do i achieve this ?我如何实现这一目标? In FB authentication, they have provided an end point to which i post the access token (https://graph.facebook.com/app?access_token=) and it gives the expiry time, validity of token etc.在 FB 身份验证中,他们提供了一个端点,我将访问令牌发布到该端点(https://graph.facebook.com/app?access_token=) ,它给出了令牌的到期时间、有效性等。

How do we do this with LinkedIn api, i searched their documentation, but no luck.我们如何使用 LinkedIn api 做到这一点,我搜索了他们的文档,但没有运气。 Any help will be appreciated.任何帮助将不胜感激。

Thanks谢谢

There's no separate API that LinkedIn provides to inspect the token. LinkedIn没有提供可检查令牌的单独API。 However you do get a hint about the token expiry back in the response from the token endpoint when exchanging the code for an access_token in the expires_in parameter, eg: 但是,当在expires_in参数中将code交换为access_token ,您确实会从令牌端点的响应中得到关于令牌到期的提示,例如:

   {"access_token":"<>","expires_in":5183999}

which tells you that it is valid for 60 days. 告诉您有效期为60天。 You could store that information together with the access token. 您可以将该信息与访问令牌一起存储。

You can use "Token Introspection" endpoint to check the validity of your access token at any time.您可以随时使用“令牌自省”端点来检查您的访问令牌的有效性。 https://docs.microsoft.com/en-us/linkedin/shared/authentication/token-introspection . https://docs.microsoft.com/en-us/linkedin/shared/authentication/token-introspection Use Refresh token to refresh it before it expires.使用刷新令牌在过期前刷新它。

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

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