英文:
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
方法拆分为两部分,将omniauthable
和omniauth_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]
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论