简体   繁体   English

具有devise令牌auth的Grape,无法使用身份验证方法

[英]Grape with devise token auth, authenticate methods not available

I have a rails app with grape integrated, i tried to integrate devise token auth, and i was able to sign up/sign in with the urls mentioned in the pdf. 我有一个集成了Grape的Rails应用程序,我尝试集成devise令牌auth,并且能够使用pdf中提到的网址进行注册/登录。

But i do face a problem with grape i could nt use methods like user_signed_in? 但是我确实遇到了葡萄问题,我无法使用诸如user_signed_in之类的方法吗? or authenticate_user! 或authenticate_user! inside grape api, included concerns in user model or controller doesnt work here. 在Grape api中,用户模型或控制器中包含的问题在这里不起作用。

i have tried to integrate these methods inside the grape by calling some files like 我试图通过调用一些文件来将这些方法集成到葡萄中

require  '........'

Is there any way to require files and call these methods inside grape api. 有什么方法可以要求文件并在grape api中调用这些方法。

Have you resolved this issue? 您解决了这个问题吗? There is a specific gem that uses devise_token_auth that works with grape. 有一个使用devise_token_auth的特定gem与grape一起使用。 https://github.com/mcordell/grape_devise_token_auth . https://github.com/mcordell/grape_devise_token_auth Setting that up should help solve your issue. 进行设置应有助于解决您的问题。

GrapeDeviseTokenAuth gem is a compatibility layer between devise_token_auth and grape. GrapeDeviseTokenAuth gem是devise_token_auth和grape之间的兼容层。 It is useful when mounting a grape API in a rails application where devise (or devise_token_auth + devise) is already present. 当在已经存在devise(或devise_token_auth + devise)的rails应用程序中安装grape API时,这很有用。 It is reliant on devise_token_auth and devise, therefore it is not suitable for grape where these are not present. 它依赖devise_token_auth和devise,因此不适用于不存在这些对象的葡萄。 If you are looking for a pure grape solution, you should check out grape_token_auth. 如果您正在寻找纯葡萄的解决方案,则应签出grape_token_auth。

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

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