###前提・実現したいこと
Ruby on Rails でTwitterのツイート機能を実装したい
###発生している問題・エラーメッセージ
Twitter::Error::Unauthorized in TopController#tweet
エラーメッセージ Invalid or expired token. ###該当のソースコード class TopController < ApplicationController skip_before_action :authenticate tweet def tweet client = Twitter::REST::Client.new do |config| applicationの設定 config.consumer_key = Settings.twitter_key config.consumer_secret = Settings.twitter_secret ユーザー情報の設定 user_auth = current_user.authentications.first config.access_token = user_auth.token config.access_token_secret = user_auth.secret end Twitter投稿 client.update(params[:text]) redirect_to root_path, notice: 'ツイートしました!' end end
###試したこと
permissionを読み書きに変更した
アクセストークンを生成し直した
TwitterのAPIキーも確認し、生成し直した
###補足情報(言語/FW/ツール等のバージョンなど)
より詳細な情報
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/07/07 03:27