Android 包含已具有值的字段的HTTP Post表单数据
我正在尝试将Jasig CAS的本机登录添加到我的Android应用程序中。我正在使用OkHttp(和/或改装)执行HTTP post操作。HTML登录表单如下所示:Android 包含已具有值的字段的HTTP Post表单数据,android,forms,http-post,retrofit,okhttp,Android,Forms,Http Post,Retrofit,Okhttp,我正在尝试将Jasig CAS的本机登录添加到我的Android应用程序中。我正在使用OkHttp(和/或改装)执行HTTP post操作。HTML登录表单如下所示: <form id="form1" name="login" class="fm-v" action="/cas/login" method="post"> <input type="hidden" name="lt" value="LT-{login ticket}"> <input
<form id="form1" name="login" class="fm-v" action="/cas/login" method="post">
<input type="hidden" name="lt" value="LT-{login ticket}">
<input type="hidden" name="execution" value="{execution value}">
<input type="hidden" name="_event" value="submit">
<input type="text" id="username" name="username" tabindex="1"
placeholder="Username" class="textfield" autocomplete="off">
<input type="password" id="password" name="password" tabindex="2"
placeholder="Password" class="textfield" autocomplete="off">
<input type="submit" id="submit" name="submit" tabindex="3"
class="button" value="Submit">
</form>
"url.base.com/extension?post_name=post_value&..."
"login.example.com/cas/login?username={username}&password={password}"
因此我发现,当我使用OkHttp或改型时,post方法使用如下URL:
<form id="form1" name="login" class="fm-v" action="/cas/login" method="post">
<input type="hidden" name="lt" value="LT-{login ticket}">
<input type="hidden" name="execution" value="{execution value}">
<input type="hidden" name="_event" value="submit">
<input type="text" id="username" name="username" tabindex="1"
placeholder="Username" class="textfield" autocomplete="off">
<input type="password" id="password" name="password" tabindex="2"
placeholder="Password" class="textfield" autocomplete="off">
<input type="submit" id="submit" name="submit" tabindex="3"
class="button" value="Submit">
</form>
"url.base.com/extension?post_name=post_value&..."
"login.example.com/cas/login?username={username}&password={password}"
在任何浏览器中键入时,都会重定向到标准登录页面:login.example.com/cas/login
。但我发现,如果我遵循以下格式:
"login.example.com/cas/login?lt=LT-{current-login-ticket}
&execution={current-execution-value}&_event=submit&username={username}
&password={password}&submit=Submit"
我收到一个成功的登录!但我必须使用当前登录票证和执行值。因此,有没有办法根据给定的值自动填写表单数据的其余部分?或者我必须自己解析HTML响应才能获得登录票证和执行值吗