Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Instagram身份验证API未返回访问令牌_Javascript_Angularjs_Authentication_Oauth_Instagram - Fatal编程技术网

Javascript Instagram身份验证API未返回访问令牌

Javascript Instagram身份验证API未返回访问令牌,javascript,angularjs,authentication,oauth,instagram,Javascript,Angularjs,Authentication,Oauth,Instagram,instagram的“服务器端工作流”用于验证用户身份并为其提供会话访问令牌,但它不起作用。第一部分的工作原理是,我可以从这里得到一个代码: 但是,当将此代码发布到 为了获得访问令牌,它只响应“您必须提供一个客户机ID”,即使我已经将此作为表单数据的一部分提供了,这与我最初获取代码时使用的客户机ID相同 以下是我正在使用的代码: getIgToken: function (igCode) { let data = { client_id:

instagram的“服务器端工作流”用于验证用户身份并为其提供会话访问令牌,但它不起作用。第一部分的工作原理是,我可以从这里得到一个代码:

但是,当将此代码发布到 为了获得访问令牌,它只响应“您必须提供一个客户机ID”,即使我已经将此作为表单数据的一部分提供了,这与我最初获取代码时使用的客户机ID相同

以下是我正在使用的代码:

getIgToken: function (igCode) {
            let data = {
                client_id: config.imported.instagram.client_id,
                client_secret: config.imported.instagram.client_secret,
                grant_type: 'authorization_code',
                redirect_uri: 'http://localhost:5000/app/scrape',
                code: igCode
            }
            return $http({
                method: 'POST',
                url: 'https://api.instagram.com/oauth/access_token',
                data: data,
                headers: {
                    "Content-Type": "application/x-www-form-urlencoded",
                },
            })

        }
显然,其他人报告了将数据发布为json的问题,然后通过使用“application/x-www-form-urlencoded”解决了这些问题,但是现在这似乎也不起作用

以下是返回的确切错误消息:

{error_type: "OAuthException", code: 400, error_message: "You must provide a 
client_id"}
code:400
error_message:"You must provide a client_id"
error_type:"OAuthException"

授权类型应为“授权代码”

将数据对象转换为json格式,然后重试

 data: JSON.stringify(data),
您的代码将如下所示

getIgToken: function (igCode) {
            let data = {
                client_id: config.imported.instagram.client_id,
                client_secret: config.imported.instagram.client_secret,
                grant_type: 'authorisation_code',
                redirect_uri: 'http://localhost:5000/app/scrape',
                code: igCode
            }
var jsonData= JSON.stringify(data)
            return $http({
                method: 'POST',
                url: 'https://api.instagram.com/oauth/access_token',
                data: jsonData,
                headers: {
                    "Content-Type": "application/x-www-form-urlencoded",
                },
            })

        }