Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread Initiating a download with authentication
Mon, Aug 14 2017 11:42 AMPermanent Link

Matthew Jones

I would like to initiate a download using a TMenuItem action.

The easy way is
window.open(URL, '_blank');
except that there is no authentication added.

So I tried a TRequest,
Request.RequestHeaders.Values['Custom-Auth'] := 'token ' + ActiveToken;
which works fine, but the browser doesn't do anything with the content (even though the server says it is a download etc).

So I figured a THTMLForm would work, but I cannot set a custom header, and it seems to be low level so hard to intercept.


Anyone know how to do this? I could create a TLink I guess, and have the user click it, but if it can be done programmatically, that would be ideal. Hmm, except that there is no way to add the authentication to that either...

--

Matthew Jones
Mon, Aug 14 2017 12:07 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< Anyone know how to do this? I could create a TLink I guess, and have the user click it, but if it can be done programmatically, that would be ideal. Hmm, except that there is no way to add the authentication to that either... >>

In such a case, you want to handle the authentication via session-only cookies that the back-end will use to authenticate the user:

https://www.elevatesoft.com/manual?action=viewcomp&id=ewb2&comp=TCookies

Session-only cookies are discussed here:

https://www.elevatesoft.com/manual?action=viewmethod&id=ewb2&comp=TCookies&method=Set

As for the EWB portion, you can then use a THTMLForm container, a TLink, or a new window/tab to initiate the action and the cookies will get sent over along with the HTTP request.

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Aug 15 2017 6:16 AMPermanent Link

Matthew Jones

Tim Young [Elevate Software] wrote:

> In such a case, you want to handle the authentication via session-only cookies that the back-end will use to authenticate the user:

Thanks - took too long for me to work out how to get the cookie on my server, but that's not relevant to EWB. The next problem was it appeared to be working, but not doing anything. Only on the fourth try did I realise Chrome was downloading it quietly and showing me the button at the bottom of the page.

--

Matthew Jones
Tue, Aug 15 2017 12:11 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< Thanks - took too long for me to work out how to get the cookie on my server, but that's not relevant to EWB. >>

This is why I'm doing 2.07. Wink

Tim Young
Elevate Software
www.elevatesoft.com
Image