How to load a url, with username/password

KingKenny

New Member
Licensed User
Longtime User
Hello,

I'd like to load a webpage, that MAY require a username/password (like amazon.com, mail.yahoo.com or any other) from within my application (my app will supply username/pass) either using:

WebView.loadurl("www...")

or

StartActivity(PhoneIntent.OpenBrowser("www..."))

or any other way that is possible, please help

Cheers
 

warwound

Expert
Licensed User
Longtime User
The login form can be accessed using:

B4X:
document.forms['Login']

Take a look at the attached form_details.html (open it in a browser), you'll see the form contains input elements:
  • id userId, name IDToken1
    So set this field using:
    B4X:
    document.forms['Login'].IDToken1.value='my_user_id';
  • id fakePassword, name fakePassword
    Not sure what this is, some sort of security measure i'd guess.
  • id password, name IDToken2
    So set this field using:
    B4X:
    document.forms['Login'].IDToken2.value='my_pass_word';
  • id rememberMe, name rememberMe
    So set this field using:
    B4X:
    document.forms['Login'].rememberMe.checked=true;

Additionally the submit button is an input element with a type of 'image' but no 'id' or 'name' attribute - you cannot directly reference this button using javascript.

When the login form is submitted, the javascript function LoginSubmit() is executed and checks that all form fields have been correctly completed, if they have been correctly completed then the function allows the form to submit to the server, other the function prevents the form from submitting to the server.

So putting all that together i'd suggest you try to execute this javascript:

B4X:
document.forms['Login'].IDToken1.value='my_user_id';
document.forms['Login'].IDToken2.value='my_pass_word';
document.forms['Login'].rememberMe.checked=true;
LoginSubmit();

Martin.
 

Attachments

  • form_details.zip
    609 bytes · Views: 456
Upvote 0

Eric H

Active Member
Licensed User
Longtime User
I just tried what you suggested and it worked like a charm! I just donated again because I was so excited! (Also, because I realized that I was using 2 of your libraries in my app). Thanks a bunch for the help!
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
Thanks very much warwound, I just made a small donation. Grab a beer/coffee on me :)

I wonder if the 'fake' stuff was the field hint ([email protected]) and (8-12 characters)... ?

Thanks for the donations - much appreciated.

You're right about the fakePassword input element.
It sits under the password element displaying it's hint:

PHP:
<div style="position: relative" class="input_box_div left">
           <input type="text" value="8-12 characters" name="fakePassword" id="fakePassword" tabindex="101" class="fakeiInputTextBox" autocomplete="off">           
           <input type="password" name="IDToken2" id="password" class="fakeiInputAlteredTextBox" value="" title="Password" maxlength="12" autocomplete="off">
</div>

Martin.
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
Hi.

Take a look at the attached project.

If you update line 21 in the service module, with a valid username and password:

B4X:
Dim PostData As String="IDToken1=<username>&IDToken2=<password>&rememberMe=true"

Now run the project and watch the log.
Look at the HTTPResponse headers - one of these should be the 'logged in session cookie'.

Now look at the HTTPRequest documentation.
See the method:

SetHeader (Name As String, Value As String)

If the login is successful and you can retrieve the session cookie, then you can make further HTTPRequests.
In each of these HTTPRequests you would use the SetHeader method to add the session cookie to the HTTPRequest.
The server should recognise the session cookie and allow your HTTPRequests to succeed.

That's the theory, i'd suggest you update the attached project with valid username and password and just look at the response.
I ran the project as it is and could see this logged:

Set-cookie : [swyAuthCookie=AQIC5wM2LY4SfcyoheLENVwfSCa7OKJcwRnrvJr0x7g5xBo.*AAJTSQACMDQAAlMxAAIwMw..*; Domain=.tomthumb.com; Path=/, swyAuthCookie=AQIC5wM2LY4SfcyoheLENVwfSCa7OKJcwRnrvJr0x7g5xBo.*AAJTSQACMDQAAlMxAAIwMw..*; Domain=.randalls.com; Path=/, swyAuthCookie=AQIC5wM2LY4SfcyoheLENVwfSCa7OKJcwRnrvJr0x7g5xBo.*AAJTSQACMDQAAlMxAAIwMw..*; Domain=.dominicks.com; Path=/, swyAuthCookie=AQIC5wM2LY4SfcyoheLENVwfSCa7OKJcwRnrvJr0x7g5xBo.*AAJTSQACMDQAAlMxAAIwMw..*; Domain=.genuardis.com; Path=/, swyAuthCookie=AQIC5wM2LY4SfcyoheLENVwfSCa7OKJcwRnrvJr0x7g5xBo.*AAJTSQACMDQAAlMxAAIwMw..*; Domain=.pavilions.com; Path=/, swyAuthCookie=AQIC5wM2LY4SfcyoheLENVwfSCa7OKJcwRnrvJr0x7g5xBo.*AAJTSQACMDQAAlMxAAIwMw..*; Domain=.vons.com; Path=/, swyAuthCookie=AQIC5wM2LY4SfcyoheLENVwfSCa7OKJcwRnrvJr0x7g5xBo.*AAJTSQACMDQAAlMxAAIwMw..*; Domain=.safeway.com; Path=/, swyAuthCookie=AQIC5wM2LY4SfcyoheLENVwfSCa7OKJcwRnrvJr0x7g5xBo.*AAJTSQACMDQAAlMxAAIwMw..*; Domain=.carrsqc.com; Path=/, swyConsumerlbcookie=03; Domain=.randalls.com; Path=/, swyConsumerlbcookie=03; Domain=.dominicks.com; Path=/, swyConsumerlbcookie=03; Domain=.tomthumb.com; Path=/, swyConsumerlbcookie=03; Domain=.genuardis.com; Path=/, swyConsumerlbcookie=03; Domain=.pavilions.com; Path=/, swyConsumerlbcookie=03; Domain=.vons.com; Path=/, swyConsumerlbcookie=03; Domain=.safeway.com; Path=/, swyConsumerlbcookie=03; Domain=.carrsqc.com; Path=/, SWY_LOGIN_COUNT=1; Path=/, swyAuthCookie=LOGOUT; Domain=.randalls.com; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/, swyAuthCookie=LOGOUT; Domain=.dominicks.com; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/, swyAuthCookie=LOGOUT; Domain=.tomthumb.com; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/, swyAuthCookie=LOGOUT; Domain=.genuardis.com; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/, swyAuthCookie=LOGOUT; Domain=.pavilions.com; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/, swyAuthCookie=LOGOUT; Domain=.vons.com; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/, swyAuthCookie=LOGOUT; Domain=.safeway.com; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/, swyAuthCookie=LOGOUT; Domain=.carrsqc.com; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/, JSESSIONID=33c1a5afb4dd39d7601ea90e1b14; Path=/opensso; Secure]swyAuthCookie=AQIC5wM2LY4SfczY9YLMzrWq5Se6mLzmCHRkpfeiR14g6EM.*AAJTSQACMDQAAlMxAAIwNQ..*; Domain=.randalls.com; Path=/, swyAuthCookie=AQIC5wM2LY4SfczY9YLMzrWq5Se6mLzmCHRkpfeiR14g6EM.*AAJTSQACMDQAAlMxAAIwNQ..*; Domain=.dominicks.com; Path=/, swyAuthCookie=AQIC5wM2LY4SfczY9YLMzrWq5Se6mLzmCHRkpfeiR14g6EM.*AAJTSQACMDQAAlMxAAIwNQ..*; Domain=.genuardis.com; Path=/, swyAuthCookie=AQIC5wM2LY4SfczY9YLMzrWq5Se6mLzmCHRkpfeiR14g6EM.*AAJTSQACMDQAAlMxAAIwNQ..*; Domain=.pavilions.com; Path=/, swyAuthCookie=AQIC5wM2LY4SfczY9YLMzrWq5Se6mLzmCHRkpfeiR14g6EM.*AAJTSQACMDQAAlMxAAIwNQ..*; Domain=.vons.com; Path=/, swyAuthCookie=AQIC5wM2LY4SfczY9YLMzrWq5Se6mLzmCHRkpfeiR14g6EM.*AAJTSQACMDQAAlMxAAIwNQ..*; Domain=.safeway.com; Path=/, swyAuthCookie=AQIC5wM2LY4SfczY9YLMzrWq5Se6mLzmCHRkpfeiR14g6EM.*AAJTSQACMDQAAlMxAAIwNQ..*; Domain=.carrsqc.com; Path=/, swyConsumerlbcookie=04; Domain=.randalls.com; Path=/, swyConsumerlbcookie=04; Domain=.dominicks.com; Path=/, swyConsumerlbcookie=04; Domain=.tomthumb.com; Path=/, swyConsumerlbcookie=04; Domain=.genuardis.com; Path=/, swyConsumerlbcookie=04; Domain=.pavilions.com; Path=/, swyConsumerlbcookie=04; Domain=.vons.com; Path=/, swyConsumerlbcookie=04; Domain=.safeway.com; Path=/, swyConsumerlbcookie=04; Domain=.carrsqc.com; Path=/, SWY_LOGIN_COUNT=1; Path=/, swyAuthCookie=LOGOUT; Domain=.randalls.com; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/, swyAuthCookie=LOGOUT; Domain=.dominicks.com; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/, swyAuthCookie=LOGOUT; Domain=.tomthumb.com; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/, swyAuthCookie=LOGOUT; Domain=.genuardis.com; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/, swyAuthCookie=LOGOUT; Domain=.pavilions.com; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/, swyAuthCookie=LOGOUT; Domain=.vons.com; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/, swyAuthCookie=LOGOUT; Domain=.safeway.com; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/, swyAuthCookie=LOGOUT; Domain=.carrsqc.com; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/, JSESSIONID=33756321f09bd7184bf36123cf92; Path=/opensso; Secure]

My attempt to login obviously failed but the HTTPResponse still contained a session cookie - not a session cookie that would be of use to authenticate further HTTPRequests though.
In fact that looks to me like an array of session cookies for various different domains.
So can you try to successfully log in and examine the log - copy/paste it into a reply and we can try to work out which of these cookie values you'd want to pass to SetHeader in order to make further HTTPRequests.

Martin.
 

Attachments

  • GetCookie.zip
    6.7 KB · Views: 344
Upvote 0

Eric H

Active Member
Licensed User
Longtime User
I am using the HttpUtils2 Library. In the log I am able to get a success message for job1, but job2 keeps failing. I am also getting a crapload of java errors and crashes that I haven't figured out yet. The code is really sloppy, but here is what I have (I stripped out my username and password from the code)

B4X:
#Region  Service Attributes
    #StartAtBoot: False
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim currentJob As Int = 1
    Dim job1 As HttpJob
    Dim job2 As HttpJob 
End Sub
Sub Service_Create
 
End Sub

Sub Service_Start (StartingIntent As Intent)
 
 
    DoJob1
     
End Sub

Sub Service_Destroy

End Sub

Sub JobDone (Job As HttpJob)
 
    Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
    Log(job1.GetString)
 
    If Job.Success = True Then
        currentJob = 2
    Else
        Log("Error in job [" & Job.JobName & "] with error [" & Job.ErrorMessage)
    End If
    Job.Release
 
    If currentJob = 2 Then
        DoJob2
        currentJob = 3
    End If
     
End Sub
Sub DoJob1

    job1.initialize("Login", Me)
    Dim Url1 As String="https://auth.safeway.com/opensso/UI/Login"
    Dim PostData1 As String="IDToken1=<*my_email*>&IDToken2=<*my_password*>&rememberMe=true"
    job1.PostString(Url1, PostData1)

End Sub

Sub DoJob2
    job2.Initialize("Add All Coupons", Me)
    Dim Url2 As String="http://www.safeway.com/IFL/Grocery/Home"
    Dim PostData2 As String=("javascript:(function(e,a,g,h,f,c,b,d){if(!(f=e.jQuery)||g>f.fn.jquery||h(f)){c=a.createElement(~script~);c.type=~text/javascript~;c.src=~http://ajax.googleapis.com/ajax/libs/jquery/~+g+~/jquery.min.js~;c.onload=c.onreadystatechange=function(){if(!b&&(!(d=this.readyState)||d==~loaded~||d==~complete~)){h((f=e.jQuery).noConflict(1),b=1);f(c).remove()}};a.documentElement.childNodes[0].appendChild(c)}})(window,document,~1.7.2~,function($,L){function OfferProcessor(c,f){var d=c;var b=0;var a=f;var e=~/Clipping1/services/clip/offers~;return{processOffers:function(l){var p=l.offers;var n=0;for(var m=0;m<p.length;m++){var o=p[m];if(o.clipStatus===~U~){n++;var g=[];var k={};k.offerId=o.offerId;k.offerPgm=o.offerPgm;g.push(k);var h={};h.clips=g;var j=JSON.stringify(h);$.ajax({type:~POST~,url:e,contentType:~application/json~,data:j});}}b=n;a();},process:function(){var g=this;$.ajax(d).done(function(h){g.processOffers(h);});},getOffersAdded:function(){return b;}};}function Counter(c){var d=c;var a=~~;var b=0;return{incrementCount:function(){b++;if(b==d){a();}},setCallback:function(e){a=e;}};}$(document).ready(function(){var c=Counter(3);var b=OfferProcessor(~/J4UProgram1/services/program/CC/offer/allocations~,c.incrementCount);var e=OfferProcessor(~/J4UProgram1/services/program/PD/offer/allocations~,c.incrementCount);var d=OfferProcessor(~/J4UProgram1/services/program/YCS/offer/allocations~,c.incrementCount);var a=function(){var f=b.getOffersAdded();var g=e.getOffersAdded();if(f+g>0){alert(~J4U - Added ~+f+~ 'Coupon Center' coupons and \n ~+g+~ 'Personalized Deals' Coupons. \n Please reload the page.~);}};c.setCallback(a);b.process();e.process();d.process();});});".Replace("~", QUOTE))
    job2.PostString(Url2, PostData2)
End Sub



Here is a copy of the logs:
B4X:
** Activity (main) Create, isFirst = true **


** Activity (main) Resume **


** Service (j4uservice) Create **


** Service (j4uservice) Start **


startService: class anywheresoftware.b4a.samples.httputils2.httputils2service
** Service (httputils2service) Create **
** Service (httputils2service) Start **


JobName = Login, Success = true


<!DOCTYPE HTML SYSTEM "file:///CMS/includes/xml/wcs/dtd/xhtml1-transitional.dtd">


<!-- Start - JSP File Name: masterLayout.jsp -->























<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
            <base href="https://www.safeway.com/ShopStores/"/>

            <title>Safeway - Sign In Page</title>
        <link rel="shortcut icon" href="/favicon.ico" type="images/x-icon" />
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta http-equiv="Content-Style-Type" content="text/css" />
        <meta content="IE=9" http-equiv="x-ua-compatible">
     
        <!-- Start - JSP File Name: defaultMetaData.jsp -->




<meta name="description" content=''/>

<meta name="keywords" content='donotsearch' />

<meta name="searchCategory" content=''/>







<!-- End - JSP File Name: defaultMetaData.jsp -->


        <link rel="stylesheet" type="text/css" href="https://www.safeway.com/CMS/assets/css/global.css"/>


        <link rel="stylesheet" type="text/css" href="https://www.safeway.com/CMS/assets/css/globalrss.css"/>
        <link rel="stylesheet" type="text/css" href="https://www.safeway.com/CMS/assets/css/yui.css" />

                <link href="https://www.safeway.com/CMS/assets/css/container.css" rel="stylesheet" type="text/css" ></link>
        <link href="https://www.safeway.com/CMS/assets/css/carousel.css" rel="stylesheet" type="text/css" ></link>

        <script language="JavaScript" type="text/javascript" src="https://www.safeway.com/CMS/assets/javascript/global.js"></script>
        <script language="JavaScript" type="text/javascript" src="https://www.safeway.com/CMS/assets/javascript/common_utilites.js"></script>
                <script language="JavaScript" type="text/javascript" src="https://www.safeway.com/CMS/assets/javascript/ufo.js"></script>
        <script language="JavaScript" type="text/javascript" src="https://www.safeway.com/CMS/assets/javascript/sotr.js"></script>
        <script language="JavaScript" type="text/javascript" src="https://www.safeway.com/CMS/assets/javascript/s_code.js"></script>
                <script language="JavaScript" type="text/javascript" src="https://www.safeway.com/CMS/assets/javascript/iframe_safeway_hosted.js"></script>
                <script language="JavaScript" type="text/javascript" src="https://www.safeway.com/CMS/assets/javascript/jquery.min.js"></script>
                <script language="JavaScript" type="text/javascript" src="https://www.safeway.com/CMS/assets/javascript/rss-isl-api.js"></script>


        <script language="JavaScript" >
            //Tell the browsers to react to the event
            if( document.captureEvents && Event.KEYUP ) {
                document.captureEvents( Event.KEYUP );
            }
            document.onkeyup = alertkey;
        </script>

                <script language="JavaScript" type="text/javascript" src="https://www.safeway.com/CMS/assets/javascript/utilities.js" ></script>
        <script language="JavaScript" type="text/javascript" src="https://www.safeway.com/CMS/assets/javascript/carousel.js" ></script>
        <script language="JavaScript" type="text/javascript" src="https://www.safeway.com/CMS/assets/javascript/container-min.js" ></script>
        <script language="JavaScript" type="text/javascript" src="https://www.safeway.com/CMS/assets/javascript/containerariaplugin.js" ></script>
        <script language="JavaScript" type="text/javascript" src="https://www.safeway.com/CMS/assets/javascript/checkEMail.js" ></script>

    </head>

 
    <a class="skiplink" href="#startcontent">Skip to main content</a>

    <body class="yui-skin-sam">
        <!-- Start - JSP File Name: defaultTracking.jsp -->




<!-- Start - JSP File Name: LogonTracking.jsp -->








<span class="invisible">
<img src='https://s2.srtk.net/www/delivery/ti.php?trackerid=670&cb=852615926&_sr_action_type=landing_signin' width='1' height='1' border='0'/>
</span>
<!-- Start - JSPF File Name: omnitureTagsBase.jspf -->
<script language="Javascript" type="text/javascript">
    s.pageName='Sign In';
    s.channel='Sign In';
    s.prop3='Sign In';
    s.prop6='safeway';
 
</script>
<script language="javascript">var s_code=s
Message longer than Log limit (4000). Message was truncated.
<HTML><HEAD>


<TITLE>Internal Server Error</TITLE>
</HEAD><BODY>
<H1>Internal Server Error - Read</H1>
The server encountered an internal error or misconfiguration and was unable to
complete your request.<P>
Reference&#32;&#35;3&#46;914eaad1&#46;1380435561&#46;cc2ad6c
</BODY></HTML>
JobName = Add All Coupons, Success = false


j4uservice_jobdone (java line: 125)
java.io.FileNotFoundException: /data/data/b4a.example/cache/1: open failed: ENOENT (No such file or directory)
    at libcore.io.IoBridge.open(IoBridge.java:416)
    at java.io.FileInputStream.<init>(FileInputStream.java:78)
    at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:197)
    at anywheresoftware.b4a.samples.httputils2.httpjob._getstring2(httpjob.java:155)
    at anywheresoftware.b4a.samples.httputils2.httpjob._getstring(httpjob.java:144)
    at b4a.example.j4uservice._jobdone(j4uservice.java:125)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
    at anywheresoftware.b4a.keywords.Common$4.run(Common.java:930)
    at android.os.Handler.handleCallback(Handler.java:725)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5328)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
    at libcore.io.Posix.open(Native Method)
    at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
    at libcore.io.IoBridge.open(IoBridge.java:400)
    ... 18 more
java.lang.RuntimeException: java.lang.RuntimeException: java.io.FileNotFoundException: /data/data/b4a.example/cache/1: open failed: ENOENT (No such file or directory)


    at anywheresoftware.b4a.keywords.Common$4.run(Common.java:933)
    at android.os.Handler.handleCallback(Handler.java:725)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5328)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: java.io.FileNotFoundException: /data/data/b4a.example/cache/1: open failed: ENOENT (No such file or directory)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:195)
    at anywheresoftware.b4a.keywords.Common$4.run(Common.java:930)
    ... 9 more
Caused by: java.io.FileNotFoundException: /data/data/b4a.example/cache/1: open failed: ENOENT (No such file or directory)
    at libcore.io.IoBridge.open(IoBridge.java:416)
    at java.io.FileInputStream.<init>(FileInputStream.java:78)
    at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:197)
    at anywheresoftware.b4a.samples.httputils2.httpjob._getstring2(httpjob.java:155)
    at anywheresoftware.b4a.samples.httputils2.httpjob._getstring(httpjob.java:144)
    at b4a.example.j4uservice._jobdone(j4uservice.java:125)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
    ... 10 more
Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
    at libcore.io.Posix.open(Native Method)
    at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
    at libcore.io.IoBridge.open(IoBridge.java:400)
    ... 18 more

I don't know what the heck I am doing though, so I'm not surprised it is not working the way I expect. I also am not sure if this is related to not doing something with an authentication cookie, or what...

Eric
 
Upvote 0

Nickelgrass

Active Member
Licensed User
Longtime User
Hi,
if the Site uses a session you can load the cookie and then insert it in the following httprequests. Thats what I did and it worked like a charm

B4X:
If response.GetHeaders.ContainsKey("Set-Cookie") Then
  cookie = response.GetHeaders.Get("Set-Cookie")
  cookie = cookie.SubString2(1,  cookie.LastIndexOf(";"))
End If
Log(cookie)

insert it in the following httpclient httprequest with
B4X:
httpr.SetHeader("Cookie", cookie)
Hope this helped a bit.
Regards
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
Adding javascript to the POST data for job2 will not execute that javascript.
The only way to execute javascript is to revert to loading the webpage in a WebView.

Martin.
 
Upvote 0

Eric H

Active Member
Licensed User
Longtime User
Thanks Nickelgrass, Martin.

Re:
Adding javascript to the POST data for job2 will not execute that javascript.
The only way to execute javascript is to revert to loading the webpage in a WebView.
Martin.
This is sad news. I had envisioned a solution that would be a service that was able to run automatically once per day without the user having to manually run the app. I was going to have everything in a service that would use the StartServiceAt to do this. Darn...

Maybe the best I can do instead is have the service start, then pop a notification saying: tap here to do 'XYZ', the user taps on the notification, the app is opened with a hidden webview and a button, the app logs the user in, the user clicks the button and the javascript is executed through the webview, the user gets a messagebox saying it is complete, user closes the app.

Any suggestions for something with less interaction?
 
Last edited:
Upvote 0

warwound

Expert
Licensed User
Longtime User
You can create a WebView in a Service Sub.
As long as the WebView is dimmed locally in a sub, not as a process global.
Whether you can use the WebView without adding it to an Activty I am not sure.

Martin.
 
Upvote 0
Top