使用POST将用户重定向到instagram登录 [英] Redirect a user to instagram login using POST

查看:125
本文介绍了使用POST将用户重定向到instagram登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个处理Instagram图片的网站上.

I am working on a website which deals with Instagram pictures.

我必须将用户定向到Instagram登录页面进行验证.此过程需要我的网站在URL中发送一些参数以进行授权.格式如下.

I have to direct the user to Instagram login page for verification. This process needs my website to send few parameters in the URL, for authorization. The format is given below.

来自instagram文档-

https://api.instagram.com/oauth/authorize/?client_id=CLIENT-ID&redirect_uri=REDIRECT-URI&response_type=code

当我使用GET请求访问Instagram URL时,它工作正常. 但是现在我想从URL中隐藏这些值,并向用户隐藏.

It works fine when I use GET request to hit the Instagram URL. But now I want to hide these values from the URL and hide it from the user.

因此,我决定编写一个JSF页面,该页面将在windows.onload中以隐藏形式提交表单参数,并改为点击Instagram URL.这样我可以隐藏参数.

So I decided to write a JSF page that will on windows.onload submit the form parameters as hidden and hit the Instagram URL instead. This way I can hide the parameters.

JSF页面

<h:body>

        <h:form  prependId="false">
            <h:inputHidden id="client_id" value="#{applicationBean.instagramClientID}" /><br/>
            <h:inputHidden id="redirect_uri" value="#{applicationBean.instagramRedirectUrl}" /><br/>
            <h:inputHidden id="response_type" value="code" />
        </h:form>

        <script type="text/javascript">
            window.onload = function submitPage() {
                document.forms[0].action="#{applicationBean.instagramAuthUrl}";
                document.forms[0].submit();
            }
        </script>
    </h:body>

但这在instagram方面失败,给出代码错误400.

But this fails from the instagram side, giving code error 400.

{"code": 400, "error_type": "OAuthException", "error_message": "You must include a valid client_id, response_type, and redirect_uri parameters"}

我检查了这些值,它们似乎都很好.我唯一注意到的是还传递了一个"form-id".我假设这是导致授权失败的原因,因为我只需要发送特定的参数.如果为true,如何使用POST请求克服这一问题?

I checked the values and they all seem to be fine. The only thing I noticed is a "form-id" also being passed. I assume this is causing the authorization failure, Since I need to send only specific parameters. If true how can I overcome this using POST request?

还是我在POST请求中做错了什么?

Or am I doing something wrong in my POST request?

谢谢.

环境:Java 1.6,JSF 2

推荐答案

尝试通过硬编码传递这些值并发布结果.

Try passing those values hardcoded and post results.

这篇关于使用POST将用户重定向到instagram登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆