Reputation: 2212
i am using smartGWT, and i want to download a file from the server, by sending a request using href link , but to download the file i need basic authentication , so is it possible to add basic authentication to a simple html href ?
the href link looks like this
String exportLink = "<A href=\"" +restlet/api/user/getUsers + "\"" + constants.HREF_STYLE + ">"+Download+"</A>";
Upvotes: 1
Views: 7453
Reputation: 5067
Your link need to have the following form:
https://username:[email protected]/path
After clicking on this link, the browser will user the given username+password to authenticate itself to the server. Please have in mind, that you publish the username+password to the user.
Update: See the comment by Yvonne: The above URL scheme is not supported any more by Chrome and IE.
Upvotes: 4
Reputation: 46861
Use server side authentication.
Get the information form user HTTP session and check whether user is authorized to download the file or not? Send an error page or proper message to the client if user is not authorized to access the file.
I want to download a file from the server, by sending a request using href link.
I have already answered this on your question SmartGWT handling file in the response body
Upvotes: -1