我面临的问题是"https://api.linkedin.com/v2/me“api的LinkedIn。当我使用v1 api时,代码运行良好。我已经更新了用于linkedIn身份验证的版本2 api的代码,当我试图使用api "https://api.linkedin.com/v2/me“获取配置文件时,我收到的错误请求失败了: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方案。
发布于 2019-07-02 09:13:39
您必须在oauth2_access_token
中传递密钥
示例:
https://api.linkedin.com/v2/me?oauth2_access_token={linkedin_key}
编辑:-
此外,在权限中,需要设置"r_liteprofile“而不是"r_basicprofile”。改变许可对我来说很有效。
https://stackoverflow.com/questions/56847093
复制相似问题