Omniauth 和 jwt_authenticatable 在 Rails 7 API 中。

huangapple go评论46阅读模式
英文:

Omniauth and jwt_authenticatable rails 7 api

问题

我正尝试在Rails API中添加通过移动应用进行社交登录的功能,但在添加omniauth时,我遇到了与已设置并正常工作的JWT和devise有关的问题。这触发了以下错误:

unexpected ',', expecting => (SyntaxError)
         :omniauthable, omniauth_providers: [:google...

只有在两种方法同时存在时才会出现此错误,但它们单独使用时都正常工作。

是否有任何想法或建议将不胜感激。

英文:

I am trying to add to the Rails API the ability to handle social signins through the mobile application, and while adding omniauth, I am having an issue with my JWT and devise that has already been setup and working. This is triggering the following error:

unexpected ',', expecting => (SyntaxError)
         :omniauthable, omniauth_providers: [:google...

This error occurs only when both methods are present, but both independently work fine.

Any ideas or suggestions would be greatly appreciated.

答案1

得分: 3

为解决此错误,我将devise方法拆分为两部分,将omniauthableomniauth_providers添加到另一个调用中。

devise :database_authenticatable, :registerable,
   :recoverable, :rememberable, :validatable,
   :jwt_authenticatable, jwt_revocation_strategy: self

devise :omniauthable, omniauth_providers: [:google_oauth2]
英文:

To solve this error I split the devise method into two, adding the omniauthable and omniauth_providers into another call.


  devise :database_authenticatable, :registerable,
     :recoverable, :rememberable, :validatable,
     :jwt_authenticatable, jwt_revocation_strategy: self

devise :omniauthable, omniauth_providers: [:google_oauth2]

huangapple
  • 本文由 发表于 2023年4月11日 05:11:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/75980765.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定