2011-07-01 26 views
3

我有一個應用程序使用OmniAuth與各種社交網絡服務(包括Linkedin)進行身份驗證,並希望發佈更新。我從omniauth的用戶有以下信息:Omniauth與LinkedIn在Rails發佈更新

linkedin_verifier: **** 
linkedin_token: ***** 
linkedin_secret: ***** 
linkedin_url: http://www.linkedin.com/pub/***** 

但無法弄清楚如何使用它來發布。我看了一下:https://github.com/pengwynn/linkedin,但它需要一個請求標記和請求祕密(我似乎只有響應標記和響應祕密),我沒有從omniauth獲得。有任何想法嗎?

回答

4

你有沒有使用你omniauth後得到的令牌和祕密試圖authorize_from_access?

客戶端= LinkedIn :: Client.new( 'your_consumer_key', 'your_consumer_secret') client.authorize_from_access(linkedin_token,linkedin_secret)

+0

這是正確的答案。如果用戶以前使用OmniAuth進行了身份驗證,則應該在數據庫中擁有帳戶信息。對於linkedin_token,linkedin_secret,請使用:User.authentications.find_by_provider('linkedin')。令牌/祕密(假設您使用的模型類似於Omniauth Railscast)。 – ghayes

+0

這不適合我。當使用該代碼時,它會將我重定向到:'auth/failure?message = invalid_response' - 如果沒有特定的代碼,我的授權很好,這意味着您的答案中的代碼會導致重定向,儘管我不確定它是如何知道的來自OmniAuth的重定向到特定的URL。 - 有什麼想法在這裏可能會出錯? – Marc

1

從鏈路(https://github.com/pengwynn/linkedin)我發現這個,

你需要先得到你的API密鑰,與他們建立一個客戶端,然後你會得到你的請求令牌和迴應。


#get your api keys at https://www.linkedin.com/secure/developer

client = LinkedIn::Client.new('your_consumer_key', 'your_consumer_secret')

rtoken = client.request_token.token

rsecret = client.request_token.secret

+0

即使我已經使用OmniAuth進行身份驗證?我不想問兩次用戶... –

相關問題