linkedin 获取配置文件 - 请求失败:禁止 (403) 错误 swift
linkedin get profile - Request failed: forbidden (403) error swift
我遇到了“https://api.linkedin.com/v2/me" api of LinkedIn. Code was working good when I was using v1 api. I have updated my code for version 2 api for linkedIn authentication and When I tried to get profile with 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"。更改权限对我有用。
我遇到了“https://api.linkedin.com/v2/me" api of LinkedIn. Code was working good when I was using v1 api. I have updated my code for version 2 api for linkedIn authentication and When I tried to get profile with 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"。更改权限对我有用。