HTTP Post with basic authentication (username/password)

1,615 views
Skip to first unread message

Brian Gaugler

unread,
Sep 4, 2013, 1:25:51 PM9/4/13
to tas...@googlegroups.com

This question is coming from a fellow developer.  I've implemented Tasker integration in my app, so I'm hoping you'll help me out on this question although it has no benefit to Tasker community.

I am trying to allow users to send an HTTP POST request to their custom server.  I am told that it needs to allow for "Basic Authentication" to incorporate username and password to login to the web server when it makes this post.   And it needs to be done on the app side.   I am told that Tasker knows how to do this, and had it implemented, for those this same user who was trying to connect to Homeseer server.

HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(serverUrl);
result = httpclient.execute(httppost);


I tried setting the serverURL to: http://username:password@www.site.com/page.aspx
but this did not work.  Server returned: unauthenticated.

So how is the app supposed to do this basic auth ?   I am hoping it is simply enough that someone wouldn't mind just sending over an answer.

Thank you kindly!!

Pent

unread,
Sep 5, 2013, 2:18:26 AM9/5/13
to tas...@googlegroups.com

I am trying to allow users to send an HTTP POST request to their custom server.  I am told that it needs to allow for "Basic Authentication" to incorporate username and password to login to the web server when it makes this post.   And it needs to be done on the app side.   I am told that Tasker knows how to do this, and had it implemented, for those this same user who was trying to connect to Homeseer server.

HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(serverUrl);
result = httpclient.execute(httppost);


I don't use HttpClient so can't comment on what you might need to do with that as regards settings, request method etc.

With HttpUrlConnection I use:

connection.setRequestProperty(
       "Authorization", "Basic "+ Base64.encodeString( usernamePassword )
);

Pent

Brian Gaugler

unread,
Sep 5, 2013, 10:06:27 PM9/5/13
to tas...@googlegroups.com

Thank you very much for the reply...it will at least help me figure it out if I can't do it exactly like that

--
You received this message because you are subscribed to a topic in the Google Groups "Tasker" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tasker/326a6SpKoU0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tasker+un...@googlegroups.com.
Visit this group at http://groups.google.com/group/tasker.
For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages