0
我正在處理Instagram照片的網站上工作。使用POST將用戶重定向到instagram登錄
我必須指導用戶到Instagram登錄頁面進行驗證。這個過程需要我的網站在URL中發送很少的參數來進行授權。格式如下。
從Instagram的文檔 -
https://api.instagram.com/oauth/authorize/?client_id=CLIENT-ID&redirect_uri=REDIRECT-URI&response_type=code
它,當我使用GET請求來打Instagram的URL工作正常。 但現在我想隱藏URL中的這些值並將其從用戶隱藏。
因此,我決定編寫一個JSF頁面,它將在windows.onload中提交表單參數作爲隱藏,然後打開Instagram URL。這樣我可以隱藏參數。
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
{"code": 400, "error_type": "OAuthException", "error_message": "You must include a valid client_id, response_type, and redirect_uri parameters"}
我檢查的價值和它們似乎都被罰款。我唯一注意到的是一個「form-id」也被傳遞。我認爲這是導致授權失敗,因爲我只需要發送特定的參數。如果是的話我怎麼才能克服這個使用POST請求?
或者我在POST請求中做錯了什麼?
在此先感謝。
環境:Java 1.6的,JSF 2
任何人都可以拋出一些光? – Akshat