Opening url from android, which requires basic authentication

1.6k Views Asked by At

Overview : I'm trying to make an android application for my college email service. Its hosted by Zimbra, Webmail. Im using Jaunt-Api to scrape data from the website.

My question is: I have the link (url) to the attachment. When I open the link using the following code, I get an HTTP 403 error. This means I have to add a basic authentication to this URL. Ive tried for over 6 hours, gone through many such questions on stackoverflow already but couldnt find an answer. How do I add basic authentication to this code?

Intent intent = new Intent(Intent.ACTION_VIEW);
Uri data = Uri.parse(currentemail.attatchment_link);
intent.setData(data);
startActivity(intent);

Otherwise, can anybody suggest a direct way to download the attachment on android? (Given, I have the link, I just need to add the authentication which I have struggled for days now!).

2

There are 2 best solutions below

0
On

Did you try appending the username and password to the URL itself? https://gooduser:[email protected]/webcallback?foo=bar

0
On

Try adding username and password in the beginning of the link like url : www.example.com

try this: www.username:[email protected]

Then use DownloadManager to catch the dowload from the link.