問題描述
Linkedin oauth2 r_liteprofile 沒有從 api 返回 (Linkedin oauth2 r_liteprofile not being returned from api)
所以我有一個 Rails 應用程序,我正在使用 這個用於 oauth2 的 gem。現在在linkedin的開發者控制台上,我只能選擇
r_basicprofile
、r_emailaddress
、rw_company_admin
和w_share</代碼>。
所以我選擇了 r_basicprofile
。
現在一旦確定linkedin在推送用戶到http://localhost:3000/auth/linkedin/callback?error=unauthorized_scope_error&error_description=Scope+%26quot%3Br_liteprofile%26quot%3B+is +not+authorized+for+your+application&state=126bb5cb16613e67f77580954980f86e4a3080c7cb4e56fe
這顯然是在請求 r_liteprofile
。現在由於 r_liteprofile
是不允許的,它會給出一個回調錯誤
OmniAuth::Strategies::OAuth2::CallbackError
<代碼>unauthorized_scope_error | 範圍“r_liteprofile” 沒有為您的應用程序授權
。
routes.rb 看起來像
get 'login‑linkedin', to: redirect('/auth/linkedin' )
get 'auth/:provider/callback', to: 'sessions#identify_network_entry'
omniauth.rb 看起來像
提供者 :linkedin, 'KEY', 'VALUE
Linkedin 控制台中 Oauth2.0 的回調 url 看起來像
http://localhost:3000/auth/linkedin/callback
是否有解決方法或者這是一個實施缺陷?這不再偶爾發生,所以我假設我正在犯一個實施錯誤。
參考解法
方法 1:
Today (jan 14th) linkedin transitioned their docs and allowed for all applications created after today to automatically be able to use r_liteprofile under the self serve section, but to use the r_basicprofile you'll have to apply to their partner program.
Connecting to the v1 API with r_basicprofile should work, but only until march 1st.
Perhaps your issue was happening because of the switch that took place.
Read more here:
All new applications created on the LinkedIn Developer Platform as of January 14, 2019 can use LinkedIn's v2 APIs.
Specifically...
What permissions do I have access to?
LinkedIn v1 APIs provided the following set of permissions:
r_basicprofile r_emailaddress w_share rw_company_admin
Moving forward, the available v2 APIs include:
r_liteprofile (replaces r_basicprofile) r_emailaddress w_member_social (replaces w_share)
and ...
Looking to maintain access to the Basic Profile fields? Learn more about applying to a LinkedIn Partner Program.
(by Himanshu Gupta、amurrell)