3

WePay 戦略を使用して Omniauth をセットアップしました ( https://github.com/intridea/omniauth )。承認を取得するとき、v2/oauth2/token呼び出しを 4 回行います (呼び出しが散在し/v2/userます) が、変数内の最初のアクセス トークンで戻りenv["omniauth.auth"]ます。これにより、コールバックの読み込み時間が長くなり、後で API 呼び出しを実行しようとすると「access_token revoked」エラーが発生します。

なぜこれが起こっているのか、私は完全に困惑しています。コールバックに続くすべてのメソッドを無効にしようとしたので、私のアプリ (Rails にあります) とは対照的に、これは Omniauth 自体の中で起こっていると確信しています。

これが私のomniauth.rb初期化ファイルです:

require "omniauth/strategies/wepay"
 OmniAuth.config.logger = Rails.logger
 Rails.application.config.middleware.use OmniAuth::Builder do
   provider :wepay, ENV['WEPAY_STAGE_APP_ID'], ENV['WEPAY_STAGE_SECRET']
   provider :twitter, ENV['TWITTER_CONSUMER_KEY'], ENV['TWITTER_CONSUMER_SECRET']
   provider :facebook, ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_APP_SECRET']
 end

関連ルート:

match 'auth/wepay/callback', to: 'sessions#wepay'
match 'auth/failure', to: redirect('/organization')

セッションコントローラー (ただし、これが呼び出される前にループが発生していると確信しています):

class SessionsController < ApplicationController
  before_filter :get_all_organizations
  before_filter :authorize_current_organization

  def wepay
    current_user.from_omniauth(env["omniauth.auth"])
    if @organization.wepay_account_id? == false
      @organization.create_wepay_account(current_user)
    end

    redirect_to transactions_path, notice: 'Login successful.' 
  end
end

私のログの関連セクション:

Started GET "/auth/wepay/" for 127.0.0.1 at 2012-08-26 17:40:18 -0700
(wepay) Request phase initiated.


Started GET "/auth/wepay/callback?code=XXXXX&state=XXXXX" for 127.0.0.1 at 2012-08-26 17:40:25 -0700
(wepay) Callback phase initiated.
Connected to NewRelic Service at collector-6.newrelic.com
Processing by SessionsController#wepay as HTML
  Parameters: {"code"=>"XXXXX", "state"=>"XXXXX"}

私はこれをデバッグするのに苦労していますが、New Relic は 548sessions#wepayミリ秒がNet::HTTP[stage.wepayapi.com]: POST. それが何かを示しているかどうかはわかりません。

4

1 に答える 1

0

かっこいい、チェックするだけ。私の側では、テストとして、Rails Omniauthの既成のアプリをいくつか実行しました。どちらも簡単に認証して、アプリに戻ることができました。これらを使用してアプリを作成しました:http: //net.tutsplus.com/tutorials/ruby/how-to-use-omniauth-to-authenticate-your-users/ および http://railsapps.github.com/tutorial -rails-mongoid-omniauth.html

ルーティングの問題だけではない可能性があるため、セッションコントローラのコードを確認します。

于 2012-08-27T06:45:38.133 に答える