【问题标题】:linkedin get profile - Request failed: forbidden (403) error swiftlinkedin 获取配置文件 - 请求失败:禁止(403)错误迅速
【发布时间】:2019-11-12 18:49:42
【问题描述】:

我遇到了 LinkedIn 的“https://api.linkedin.com/v2/me”api 的问题。当我使用 v1 api 时,代码运行良好。我已经更新了用于linkedIn 身份验证的版本2 api 的代码,当我尝试使用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 方案。

【问题讨论】:

  • 检查 oauth 权限。

标签: ios swift iphone linkedin linkedin-api


【解决方案1】:

你必须输入oauth2_access_token的密钥

示例:

https://api.linkedin.com/v2/me?oauth2_access_token={linkedin_key}

编辑:-

还需要设置“r_liteprofile”而不是“r_basicprofile”。更改权限对我有用。

【讨论】:

  • 根据您的代码,您必须设置:让 url = "api.linkedin.com/v2/me?oauth2_access_token={token} 检查并告诉我。
  • 感谢您的解决方案。经许可,我使用了“r_basicprofile”,并将其更改为“r_liteprofile”后效果很好。非常感谢您的回复。 :)
  • 如果我的解决方案解决了您的问题,请选择它作为您的答案。谢谢
猜你喜欢
  • 1970-01-01
  • 2015-04-15
  • 1970-01-01
  • 2016-10-25
  • 2016-08-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多