我正在使用oauth嘗試通過基於this指南的venmo登錄。這不是官方的,venmo文檔甚至沒有用ruby顯示代碼示例。Venmo/Oauth缺失參數:client_id。,code:241
起初,我甚至看不到venmo登錄。我在初始化程序中刪除了ENV和括號中的id和括號,然後我可以看到登錄信息。當我提出和它打回電話我得到這個錯誤:(我認爲它重不休......我必須手動關閉服務器)
{"error": {"message": "Missing argument: client_id.", "code": 241}}
I, [2014-04-16T11:49:48.124423 #47700] INFO -- omniauth: (venmo) Callback phase initiated.
E, [2014-04-16T11:49:48.345202 #47700] ERROR -- omniauth: (venmo) Authentication failure! invalid_credentials: OAuth2::Error, {"message"=>"Missing argument: client_id.", "code"=>241}:
這裏是我的路線:
get 'users/auth/venmo/callback' => 'omniauth_callbacks_controller#create'
寶石:
gem 'devise'
gem 'omniauth'
gem 'omniauth-venmo'
我有這個在我的初始化/ omniauth.rb
Rails.application.config.middleware.use OmniAuth::Builder do
provider :venmo, 'id', 'secret', :scope => 'access_feed,access_profile,access_friends,make_payments'
end
這是我的回調控制器
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
def venmo
@user = User.find_for_oauth(env["omniauth.auth"], current_user)
raise
if @user.persisted?
sign_in_and_redirect root_path, :event => :authentication
set_flash_message(:notice, :success, :kind => "Venmo") if is_navigational_format?
else
session["devise.venmo_uid"] = env["omniauth.auth"]
redirect_to new_user_registration_url
end
end
protected
def auth_hash
request.env['omniauth.auth']
end
末
,我必須初始化/ devise.rb
require 'omniauth-venmo'
config.omniauth :venmo, "KEY", "SECRET"
- 充滿過程中的價值。我將不勝感激...... 謝謝!
更新:我已經推到github存儲庫和我的同行之一拉它。他沒有得到同樣的錯誤。這是什麼原因..?
如果加回'ENV [ 'VENMO_CLIENT_ID']'和'ENV [ 'VENMO_CLIENT_SECRET'] '然後在運行你的rails進程之前設置環境變量(例如'export VENMO_CLIENT_ID = whatever'在同一個終端中),那麼它是否工作? – agf
我試過使用$ export,並且是的。仍然沒有骰子 – Peege151
你會得到什麼錯誤? – agf