简体   繁体   English

Rails API访问令牌

[英]Rails API access_token

I am creating an API using rails. 我正在使用Rails创建API。 When a user logs in (passes in username/password), rather than setting a cookie, I want to respond with a 'token' that I want to send the client. 当用户登录(传递用户名/密码)而不是设置cookie时,我想使用要发送给客户端的“令牌”进行响应。 This token probably has an expiration date on it and the user_id i store internally which links the token with the user, etc. Is there a tutorial or gem I can use? 该令牌上可能有一个失效日期,并且我在内部存储了user_id,该用户链接将令牌与用户联系起来,等等。是否可以使用教程或gem? Thanks 谢谢

Railscasts.com上有专门针对同一期的精彩插曲 ,值得一看。

如果您只是在寻找一种发送令牌的方法(而不是用来处理整个过程的gem),则可以使用render inline: "token" (或json等效项)

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

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