0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

deviseを使ったtwitter認証でコケた話

Last updated at Posted at 2024-12-02

環境

  • ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [arm64-darwin20]
  • Rails 6.1.4

内容

[Rails] deviseの使い方(rails6版)の記事を参考にdeviseを実装していたところTwitterで認証するところでコケた。

terminal
D, [2021-07-17T13:20:36.167758 #35278] DEBUG -- omniauth: (twitter) Request phase initiated.
W, [2021-07-17T13:20:36.168254 #35278]  WARN -- omniauth: Attack prevented by OmniAuth::AuthenticityTokenProtection
E, [2021-07-17T13:20:36.168409 #35278] ERROR -- omniauth: (twitter) Authentication failure! authenticity_error: OmniAuth::AuthenticityError, Forbidden

ページの方でもエラーが発生(何書いてあるか忘れた)

解決

gemにomniauth-rails_csrf_protectionを追加する。

gemfile
gem 'omniauth-rails_csrf_protection'

よくよく調べるとomniauth:2.0から必要になるGemだそうです

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?