今、deviseとOmniAuthを用いて新規登録、ログイン周りの実装をしています。
そこで、OAuth::Unauthorized 401 Authorization Requiredというエラーが出ました。
調べて見たところ、以下のサイトを見ると良いと書いてあったので試したのですが、うまくいきませんでした。
https://qiita.com/hirokishirai/items/5a43977a38ecd922bfb9
おそらく原因は、TwitterAPI?のApplication Managementで開発用と本番用二つ作ってあって、そこのAPIkeyとAPIsecretkeyがごちゃごちゃになってしまっているのではないかと思っています。
そこで質問なのですが、こちらのsecrets.ymlで3,4は開発用のkeyを入れて、本番用のはターミナル上でコマンド打って登録して、1,2,5,6は全て同じもので、bundle exec rake secretで打って出てきた文字列を入れているのですが、これは間違っているのでしょうか?初心者質問ですみません。ぜひお時間あればご回答いただきたいです。
development: secret_key_base: 1 test: secret_key_base: 2 # Do not keep production secrets in the unencrypted secrets file. # Instead, either read values from the environment. # Or, use `bin/rails secrets:setup` to configure encrypted secrets # and move the `production:` environment over there. # production: # secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> #Twitterログイン機能の実装 default_twitter: &default_twitter twitter_api_key: '3' twitter_api_secret: '4' development: secret_key_base: 5 <<: *default_twitter test: secret_key_base: 6 <<: *default_twitter production: secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> twitter_api_key: <%= ENV["TWITTER_CONSUMER_KEY"] %> twitter_api_secret: <%= ENV["TWITTER_CONSUMER_SECRET"] %>
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。