Rails JSON API 的基于令牌的身份验证 [英] Token based authentication for Rails JSON APIs

查看:24
本文介绍了Rails JSON API 的基于令牌的身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Rails 中制作 API.对于普通身份验证,我们使用设计,但在 API 中如何实现设计以进行身份​​验证.

I make API in rails. For normal authentication we use devise but in API how to implement devise for authentication.

gem 'devise_token_auth'

有人更喜欢这个 gem 进行身份验证,但没有可用的教程.rails api中如何实现鉴权?

Someone prefer this this gem for authentication but there are no tutorial available for that. How to implement authenitication in rails api?

推荐答案

这里有一个关于 使用 devise_token_auth 进行 API 身份验证.此外,devise_token_auth gem 的 github 页面 似乎有一个非常好的文档,应该可以帮助您入门.

Here is a good tutorial on API authentication with devise_token_auth. Also, the devise_token_auth gem's github page seems to have a very good documentation which should help you get started.

如果您正在寻找一个很好的教程来理解相关概念,这里是一个,其中有一个关于创建具有基于令牌的身份验证的 Rails API 的完整演练(不使用 devise_token_auth,但有助于理解概念).

If you are looking for a good tutorial to understand the related concepts, here is one that has a thorough walkthrough of creating a Rails API with token-based authentication (Not using devise_token_auth, but useful to understand the concepts).

我还建议您查看 JWT (JSON Web Token),其中适用于大规模 Rails API.这是另一个教程,解释了如何构建 Rails API由 JWT 支持

I also recommend you to take a look at the JWT (JSON Web Token) which works very well with large scale Rails API. Here is another tutorial that explains how to build Rails API Backed With JWT

这篇关于Rails JSON API 的基于令牌的身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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