WinINet and basic auth

308 views
Skip to first unread message

Dave S

unread,
Feb 23, 2016, 3:39:27 PM2/23/16
to web2py-users
I'm trying to use Basic Auth with my restful service; see
for my starting point, although I'm doing a post.

curl --request POST -TransferEncoding C:\dir1\test1.txt --user userx@servery.com:pwd1 http://ww.zz.uu.39/uploader/default/shove/upstuff/test1.txt

This works fine from the command line (centos or Win7, as long as curl is installed).

And I successfully used this with libcurl in my Windows test client ("us...@servery.com" --> "user%40servery.com").  Tcpdump on the server shows the u/p fields moved to an "Authorization:" header (Basic).

When I try this from WinINet functions, the u/p stuff in the URL is stripped but no "Authorization:" header is added.  Setting the u/p in InternetConnect() seems to be ignored.  As a result, I get back a 303 redirecting to the login page.  (I'm using shake-the-box Rocket server for prototyping, though I plan to move to nginx later.)
This MS page suggests that WinINet is expecting a 401, although it isn't clear that applies to Basic Auth or just challenge-response authentication.

Some StackOverflow hits suggest that I need to prepare the Basic Auth header myself and use the lpszHeaders parameter of HttpSendRequest().  Is that my only choice, or am I missing something?

Thanks.

Dave
/dps




 

Dave S

unread,
Feb 24, 2016, 7:06:20 PM2/24/16
to web2py-users


On Tuesday, February 23, 2016 at 12:39:27 PM UTC-8, Dave S wrote:
I'm trying to use Basic Auth with my restful service; see
for my starting point, although I'm doing a post.


Also, does Web2Py support Digest auth?

/dps

Niphlod

unread,
Feb 25, 2016, 3:12:28 AM2/25/16
to web2py-users
if wininet can't do basic auth, is it web2py's fault ?!?!?!
curl is available also on windows :-P and it's pretty much the de-facto reference. if it works with curl but not with wininet, it's wininet fault.

as for digest auth, no, web2py doesn't support it out of the box.

Dave S

unread,
Feb 25, 2016, 4:19:41 AM2/25/16
to web2py-users
On Thursday, February 25, 2016 at 12:12:28 AM UTC-8, Niphlod wrote:
if wininet can't do basic auth, is it web2py's fault ?!?!?!
curl is available also on windows :-P and it's pretty much the de-facto reference. if it works with curl but not with wininet, it's wininet fault.

So it seems.
 

as for digest auth, no, web2py doesn't support it out of the box.


Alas.

/dps

Niphlod

unread,
Feb 25, 2016, 8:25:26 AM2/25/16
to web2py-users
oddly enough there's a "libcurl vs wininet" page on curl's site ...

Dave S

unread,
Feb 26, 2016, 2:48:37 AM2/26/16
to web2py-users


On Thursday, February 25, 2016 at 5:25:26 AM UTC-8, Niphlod wrote:
oddly enough there's a "libcurl vs wininet" page on curl's site ...



Oddly enough, nothing there was particularly surprising.
Reply all
Reply to author
Forward
0 new messages