Instagram访问令牌过期 [英] Instagram access token expire

查看:156
本文介绍了Instagram访问令牌过期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,可以从我的Instagram帐户中提取数据. 我曾经授权过此应用一次,并获得了访问令牌.但是我很担心 如果该令牌过期怎么办?我是否应该每次都授权该应用 令牌到期? 我可以从验证码中收到另一个访问令牌吗? 如果没有,我该怎么做才能让我的应用始终从帐户中提取数据 没有我的参与? 谢谢.

I have an app, that pulls data from my Instagram account. I authorized this app once, and got access token. But I'm worried, what if this token expires? Should I authorized the app each time the token expires? Can I receive another access token from the auth code? If no, what can I do to have my app always pulling data from account without my participation? Thanks.

推荐答案

但是我担心,如果该令牌过期,该怎么办?

But I'm worried, what if this token expires?

AFAIK,Instagram访问令牌目前尚未过期.

AFAIK, Instagram accesstokens don't expire currently.

注意::来自Instagram文档.

请注意,我们不包括到期时间.我们的access_tokens没有明确的到期时间,尽管您的应用应处理以下情况:用户撤销访问权限,或者我们在一段时间后使令牌过期.在这种情况下,您的响应的元数据将包含"error_type = OAuthAccessTokenError".换句话说:不要假设您的access_token永远有效.

Note that we do not include an expiry time. Our access_tokens have no explicit expiry, though your app should handle the case that either the user revokes access or we expire the token after some period of time. In this case, your response’s meta will contain an "error_type=OAuthAccessTokenError". In other words: do do not assume your access_token is valid forever.

每次令牌过期后,我都应该授权该应用程序吗?

Should I authorize the app each time the token expires?

目前,您不需要这样做,因为令牌不会过期.随着令牌在将来失效,将会向您发送相应的警告或错误代码和消息,您需要进行处理.

At the moment, you do not need to do that, as token does not expire. As and when the token expires in future, a corresponding warning or error code and message will be sent to you, which you need to handle.

该如何做才能让我的应用始终从帐户中提取数据而无需 我的参与?

what can I do to have my app always pulling data from account without my participation?

您可以尝试以下操作:

  1. 使用sharedpreference存储访问令牌.

  1. Use sharedpreference to store the accesstoken.

首次尝试获取需要访问令牌(经过身份验证的请求)的数据时,请首先在sharedpreference中检查是否存储了访问令牌. 如果是,那么您无需登录,只需使用该访问令牌.如果您没有偏好的访问令牌,请使用instagram凭据登录,获取访问令牌,然后以共享的偏好共享它,并将其用于后续请求.

First time when you try to fetch data that needs accesstoken(Authenticated requests), first check in the sharedpreference whether the accesstoken is stored or not. if yes then you don't need to login, just use that accesstoken. If you don't have the accesstoken in preference then do the login using instagram credentials, get the accesstoken and then share it in shared preference and use that for subsequent requests.

您可以提供instagram注销选项,您只需要从sharedprefernce中清除访问令牌即可.

You can provide instagram logout option in which you just need to clear the accesstoken from sharedprefernce.

希望这对您有帮助.

这篇关于Instagram访问令牌过期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆