使用 swift 5 登录 Instagram,得到 ["error_type":OAuthException,"error_message":平台应用程序无效,"code":400]

Instagram login with swift 5, getting ["error_type": OAuthException, "error_message": Invalid platform app, "code": 400]

我正在尝试使用新文档登录 instagram 并收到类似 无效平台应用程序,"code": 400

的错误

我使用 https://api.instagram.com/oauth/authorize and after getting code i am calling https://api.instagram.com/oauth/access_token 成功获取 code 获取 access_token 但它给了我错误。

我正在关注此文档:https://developers.facebook.com/docs/instagram-basic-display-api/getting-started

请帮我解决这个问题。

提前致谢。

使用 Instagram 应用 ID、Instagram 应用密码并从收到的代码中删除#_。然后按照以下格式提出您的 post 请求。

let urlString = "https://api.instagram.com/oauth/access_token"

let appendedURI = "client_id=\(API.INSTAGRAM_CLIENT_ID)&client_secret=\(API.INSTAGRAM_CLIENTSERCRET)&grant_type=authorization_code&redirect_uri=\(API.INSTAGRAM_REDIRECT_URI)&code=\(code)"

    let url = URL(string: urlString)!

    let session = URLSession.shared
    var request = URLRequest(url: url)
    request.httpMethod = "Post"
    request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField:"Content-Type");
    request.cachePolicy = URLRequest.CachePolicy.reloadIgnoringCacheData
    request.httpBody = appendedURI.data(using: .utf8)

    let task = session.dataTask(with: request) { (data, response, error) in
        if error == nil {
        let dataString = NSString(data: data!, encoding: String.Encoding.utf8.rawValue)
        print("result=",dataString!)


let task = session.dataTask(with: request) { (data, response, error) in
            if error == nil {
            let dataString = NSString(data: data!, encoding: String.Encoding.utf8.rawValue)
            print("result=",dataString!)
                do {

                if let accDetail = try JSONSerialization.jsonObject(with: data!, options: []) as? [String : Any] {

                    let accessToken = accDetail["access_token"] as! String

                    let userID = accDetail["user_id"] as! Int64

                    completion("success", accessToken, userID)

                }

            }catch let error {



            }
        }

    }
    task.resume()