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?

More than 5 years have passed since last update.

Rails6 Twitterログインでエラー

Posted at

TwitterログインをRailsで実装したときに苦労したので簡単にメモ

Invalid Credential

どうやらomniauthを複数の箇所で定義していたのが原因だったようです。
複数の参考サイトを参照するときは注意が必要かもしれません。

config/initializers/devise.rb
Devise.setup do |config|
  config.omniauth :twitter, ENV['TWITTER_KEY'], ENV['TWITTER_SECRET'], callback_url: "http://127.0.0.1:3000/users/auth/twitter/callback"
end
config/initializers/omniauth.rb
Rails.application.config.middleware.use OmniAuth::Builder do
    provider :twitter, ENV['TWITTER_KEY'], ENV['TWITTER_SECRET']
end

401 Authorization Required

スクリーンショット 2019-12-10 19.44.37.png

TwitterのAPI Keyが違っていました

参考サイト

twtterログインとの死闘(devise+omniauth)
RailsでのTwitter認証
Rails5 Twitterログインをdevise+omniauthで実装

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?