Я работаю своим путем обучения себя Oauth-Twitter и щебетать Twitter в Ruby on Rails. Я до сих пор довольно свежий, несмотря на то, что завершил загрузку в Rails dev.
Я был в состоянии получить OAuth - Twitter, чтобы нормально функционировать, но теперь, когда я пытаюсь чирикать из приложения я получаю следующее:
Twitter::Error::Forbidden at /tweets Your credentials do not allow access to this resource.
Ошибка получает брошенной на client.update(tweet)
от моего user.rb
файл:
class User < ActiveRecord::Base
class << self
def from_omniauth(auth_hash)
user = find_or_create_by(uid: auth_hash['uid'], provider: auth_hash['provider'])
user.name = auth_hash['info']['name']
user.location = auth_hash['info']['location']
user.image_url = auth_hash['info']['image']
user.url = auth_hash['info']['urls']['Twitter']
user.oauth_token=auth_hash.credentials.token
user.oauth_secret=auth_hash.credentials.secret
user.save!
user
end
end
def tweet(tweet)
client = Twitter::REST::Client.new do |config|
config.consumer_key = Rails.application.config.twitter_key
config.consumer_secret = Rails.application.config.twitter_secret
config.access_token = oauth_token
config.access_token_secret = oauth_secret
end
client.update(tweet)
end
end
И моя схема:
ActiveRecord::Schema.define(version: 20151018214537) do
create_table "users", force: :cascade do |t|
t.string "provider", null: false
t.string "uid", null: false
t.string "name"
t.string "location"
t.string "image_url"
t.string "url"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "oauth_token"
t.string "oauth_secret"
end
add_index "users", ["provider", "uid"], name: "index_users_on_provider_and_uid", unique: true
add_index "users", ["provider"], name: "index_users_on_provider"
add_index "users", ["uid"], name: "index_users_on_uid"
end
Любая помощь, которую вы могли бы предоставить, была бы фантастической. Вы можете найти всю другую информацию на моем Github Repo
Вы подтвердили, что переменные среды на самом деле установлены? –