环回永久令牌 [英] Permanent token on loopback

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

问题描述

我正在使用Loopback API构建一个应用程序,该应用程序将由iPhone APP使用.有一个与MySQL数据库的连接,我在其中运行一些查询以获取一些结果并在API上公开.

I am building an app using Loopback API that will be consumed by an iPhone APP. There is a connection to a MySQL database where I run some queries to get some results and expose on the API.

  1. 端点包含一个ACL,该ACL仅允许经过身份验证的用户执行任何操作,包括GET操作.因此,基本上,需要使用?access_token查询字符串来完成请求.
  2. 我想设置一个令牌,该令牌可以保存在MySQL数据库上,并且可以在API上永久"使用.

我不确定是否要问正确的问题,但是如果这不是解决此问题的方法,那会是什么?

I am not sure if I am asking the right question but if this is not the way to solve this problem, what would it be?

我的主要观点是,我需要使用令牌对请求进行身份验证,但我不想在设置此令牌后就丢失它.

My main point is that I need the requests to be authenticated with a token but I don't want to lose this token once it's set.

感谢您的帮助.谢谢!

推荐答案

您可以在iOS应用发送的凭据json中传递ttl,在此示例中,令牌的有效期为60秒,仅对将令牌设为永久":

You can pass the ttl in the credential json sent by you iOS app, in this example the token will live for 60sec, just use a high value for make a token "permanent":

POST /Users/login  
{
"email":"user@email.com",
"password":"12345689",
"ttl": 60000
}

或创建一个先于远程方法来更改ttl属性,请查看本文:

Or create a before remote method to change the ttl propertie, check this article:

查看全文

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