LoginSignup
0
0

More than 3 years have passed since last update.

Twitter API で Request email address from users を Enable にしてもemailが取得できなかった

Posted at

Twitter Developers でTerms of service と Privacy Policy に記入し、Request email address from users isをEnableにしてもauth.infoの中にemailが返ってこなかった。

原因はomniauth-twitterのバージョンが古かったから。Twitter API の仕様変更で、include_emailのクエリを付与しないとメールアドレスを返してくれなくなったらしく、これはomniauth-twitter1.2.0では対応していない。
https://stackoverflow.com/questions/33292997/getting-email-back-from-twitter-oauth-with-devise-and-rails

1.4.0にバージョンを上げることで解決した。

gemfile.ruby
gem 'devise'
gem 'omniauth'
gem "omniauth-rails_csrf_protection"
gem 'omniauth-twitter', '1.4.0'
gem 'dotenv-rails'
gem 'devise-i18n'
gem 'devise-i18n-views'
$ gem list

omniauth (1.9.1)
omniauth-oauth (1.2.0)
omniauth-rails_csrf_protection (0.1.2)
omniauth-twitter (1.4.0, 1.1.0)

なぜか最新のomniauthではエラーがでて1.9.1になっている‥。

そもそものRails6へのdeviseとomniauth-twitter導入は以下の記事
https://qiita.com/cigalecigales/items/16ce0a9a7e79b9c3974e

その他の参考記事

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