Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/441.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访问令牌,无需重新加载页面_Javascript_Jquery_Authentication_Oauth 2.0_Instagram - Fatal编程技术网

Javascript 获取Instagram访问令牌,无需重新加载页面

Javascript 获取Instagram访问令牌,无需重新加载页面,javascript,jquery,authentication,oauth-2.0,instagram,Javascript,Jquery,Authentication,Oauth 2.0,Instagram,我的要求如下 我在page create.html上,我想弹出一个弹出窗口,上面写着“使用Instagram登录”。当用户单击该弹出窗口时。我想在facebook这样的弹出窗口中验证用户身份,并在不重新加载的情况下将访问令牌返回到同一页面。当我添加图片时,我将从instagram中获得一个div,其中已经包含facebook的图片,如果我刷新,这些图片将丢失 我正在成功触发请求并获取访问令牌。但我不确定如何在ajax请求中获取类似令牌的成功函数 请求: https://api.instagram

我的要求如下

我在page create.html上,我想弹出一个弹出窗口,上面写着“使用Instagram登录”。当用户单击该弹出窗口时。我想在facebook这样的弹出窗口中验证用户身份,并在不重新加载的情况下将访问令牌返回到同一页面。当我添加图片时,我将从instagram中获得一个div,其中已经包含facebook的图片,如果我刷新,这些图片将丢失

我正在成功触发请求并获取访问令牌。但我不确定如何在ajax请求中获取类似令牌的成功函数

请求: https://api.instagram.com/oauth/authorize/?client_id=XXX&redirect_uri=http://localhost:3000/auth/instagram/callback&response_type=code

res: http://localhost:3000/auth/instagram/callback?code=XXXX

如何在create.html中获取代码=XXXX

我只能使用javascript和jquery。Nodejs?不

我试着使用这个图书馆。https://github.com/Instagram/instagram-javascript-sdk 但这给了我错误。{代码:400,错误类型:OAuthException,错误消息:JS登录暂时禁用}

如果有任何方法可以像下面的facebook.com一样获取此令牌

    FB.login(
        function (response) {
            if (response.authResponse) {
            access_token =   FB.getAuthResponse()['accessToken'];
            new facebookLogin(access_token);
            }
        }
    );
或者以任何方式获取url代码=XXXX。请帮帮我


谢谢。

只需在回调页面上使用window.location.search访问查询字符串并解析代码参数。

问题是,我不想要这样的页面。我不想使用其他页面。在创建页面上,启动弹出窗口后,可以使用setTimeout监视弹出窗口中的url,使用location.href检测是否已导航到回调url。然后您可以提取代码,关闭窗口并继续。请注意,您在此处使用的是授权码授权。您需要向instagram的令牌端点执行post,以交换最终访问令牌的代码。