問題描述
OAuth2::LinkedIn 錯誤 (OAuth2::Error with LinkedIn)
我正在使用 Rails 和 OAuth,因此用戶可以使用 LinkedIn 登錄。我正在關注本教程 http://www.sitepoint.com/ rails‑authentication‑oauth‑2‑0‑omniauth/。我在 LinkedIn Developers 上註冊了我的應用程序並按照 T 的說明進行操作。但是,當使用 localhost 測試應用程序並導航到 LinkedIn 授權頁面時,我收到此 Action Controller 錯誤消息作為回調:
OAuth2::Error
invalid_request:缺少必需參數,包含無效參數值,參數不止一次。: 無法檢索訪問令牌 : appId 或重定向 uri 與授權碼不匹配或授權碼已過期 {" error_description":"缺少必填參數,包含無效參數值,參數不止一次。: 無法檢索訪問令牌 : appId 或重定向 uri 與授權碼不匹配或授權碼已過期","error":"invalid_request"}
我該怎麼做才能解決這個問題,所以使用 LinkedIn 的 OAuth 有效嗎?這是我在 omniauth.rb 中的代碼
參考解法
方法 1:
You can not set localhost directly as your callback. You can use 127.0.0.1:3000 instead of localhost to get it working.
(by user5384877、Haider)