[英]linkedin get profile - Request failed: forbidden (403) error swift
我正在使用LinkedIn的“ https://api.linkedin.com/v2/me ” api遇到問題。 當我使用v1 API時,代碼運行良好。 我已經更新了我的2版api的代碼以進行linkedIn身份驗證,並且當我嘗試使用api“ https://api.linkedin.com/v2/me ”獲取配置文件時,我收到錯誤請求失敗:禁止(403)。 我不知道該怎么解決。
這是我的代碼:
let linkedinHelper = LinkedinSwiftHelper(configuration: LinkedinSwiftConfiguration(clientId: Constant.Key.kLinkedInClientId, clientSecret: Constant.Key.kLinkedInClientSecret, state: Constant.Key.kLinkedInState, permissions: ["r_basicprofile", "r_emailaddress"], redirectUrl: Constant.Key.kLinkedInRedirectURL),nativeAppChecker: WebLoginOnly())
linkedinHelper.authorizeSuccess({ (token) in
print(token)
let url = "https://api.linkedin.com/v2/me"
linkedinHelper.requestURL(url, requestType: LinkedinSwiftRequestGet, success: { (response) -> Void in
print(response)
}) {(error) -> Void in
print(error.localizedDescription)
//handle the error
}
我也在info.plist中設置了URL方案。
您必須在oauth2_access_token
傳遞密鑰
例:
https://api.linkedin.com/v2/me?oauth2_access_token={linkedin_key}
編輯:-
同樣在權限需要設置“ r_liteprofile”而不是“ r_basicprofile”。 更改許可對我有用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.