2012-02-08 60 views
0

因此,我使用Omniauth與Twitter和Foursquare等用戶進行身份驗證。 Twitter工作正常,但Foursquare似乎沒有回報祕密。Omniauth和Foursquare無法正常工作

任何人都知道發生了什麼問題?

下面是創建在控制器的動作是,Foursquare通過用戶返回到這一點,但正如我所說,這是沒有得到的祕密,只是令牌

def create 
    omniauth = request.env["omniauth.auth"] 
    unless current_user.authentications.find_by_provider_and_uid(omniauth['provider'], omniauth['uid']) 
     current_user.apply_omniauth(omniauth) 
     current_user.save 
    end 
    flash[:notice] = "Authentication Successfull" 
    redirect_to authentications_url 
    end 

這裏是適用omniauth方法:

def apply_omniauth(omniauth) 
    authentications.build(
     :provider => omniauth['provider'], 
     :uid => omniauth['uid'], 
     :token => omniauth['credentials']['token'], 
     :secret => omniauth['credentials']['secret'] 
    ) 
    end 
+0

也許張貼一些代碼? – Simpleton 2012-02-08 13:55:12

+0

完成。沒想到這是必要的,因爲它是基本的代碼,Twitter在這方面工作得很好。 – Synthesezia 2012-02-08 17:13:31

+0

如果沒有您的omniauth版本以及您收到的錯誤代碼,診斷非常困難。 – Simpleton 2012-02-08 21:49:10

回答

0

Foursquare不應該傳回祕密,只是令牌。當您在開發者網站上註冊您的應用程序時,foursquare提供的foursquare密鑰和祕密將通過foursquare提供給您。您必須在omniauth.rb使用這些值

0

的Twitter使用OAuth 1.0和Foursquare使用2.0

這可能是你的問題有