执行利用的WebView饼干HTTP请求 [英] Perform HTTP requests using cookies from webview

查看:159
本文介绍了执行利用的WebView饼干HTTP请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这种情况下该我的应用程序显示网页视图2页的登录过程。

I have this scenario which my app shows in a webView a 2-page login process.

第一页只要求到域你打算连接。
第二个页面请求的凭据。

The first page asks only to which domain to you plan on connecting. The second page asks for the credentials.

我想在web视图进行登录,然后执行从我的家乡code的请求。
我意识到我需要从web视图中存储的cookie(但是从哪个URL?从第一页还是第二个?),然后使用cookie的原生code的请求。

I'm trying to perform the login in the webView and then execute requests from my native code. I realize I need to get the stored cookie from the webView (but from which url? from the first page or the second one?), and then use the cookie for the native code requests.

有人能告诉我怎么走呢?登录过程很简单 - 用户通过web视图登录 - 罚款。现在,我知道如何使用cookie管理,但我不知道我的cookie我想寻找 - 它是第一个登录页面的网址是什么?它是第二个?有什么关系?

Can someone please tell me how to go about it? The login process is easy - the user logs in through the webview - fine. Now, I know how to use the cookie manage but I dont know which cookie am I suppose to look for - is it the url of the first login page? is it the second one? does it matter?

接下来,我该如何使用cookie发送回服务器与一个GET请求,这样服务器就会知道我身份验证?

Next, how do I use the cookie to send back to server with a GET request so the server will know I'm authenticated?

我AP preciate的答案,我无言以对,并乞求帮助:)

I appreciate the answers I'm clueless and begging for help :)

推荐答案

最后我发现我的方式,它是pretty简单。

At the end I found my way and it was pretty simple.

一旦用户通过web视图登录 - 一个cookie设置在设备上。
后来有一次我要执行我就问cookie管理器为基于该URL设置Cookie服务的Native API调用。

Once the user logs in through the webview - a cookie is set on the device. Later on once I want to perform Native api calls on the service I ask the cookie manager for the cookie that was set based on the url.

我再取用于在服务器上进行验证,并与我的API调用一起发送它的重要标题。

I then take the important header that is used to authenticate on the server and send it along with my api calls.

这篇关于执行利用的WebView饼干HTTP请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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