I am trying to direct download some files using basic authentication from 1fichier.com, this works perfectly in browsers "https://email:password@1fichier.com/?file_ID&auth=1", but i am trying to do the same thing in my application and nothing is working... i tried request header with pure email and password, i tried header with base64 encoded email and password , i tried to send a Post request with my credentials but i always get 401 error : Unauthorized. Does Anyone Know how can i send authentication in my http request to 1fichier servers ?
This is what they provided in their Help page :
After login, a Premium member can download unlimited number of files, without limitations. !!! You MUST login to be recognized as Premium !!!
You can also direct download using "basic authentication" : https://email:password@1fichier.com/?file_ID Tip: add &auth=1 to the URL. The server will ask for an authentication. '@' of the email address is invalid with this protocol and you must use '%' instead.
Wget example : wget 'download link' --no-check-certificate --http-user='email' --http-password='password' --auth-no-challenge --content-disposition
using UnityEngine.Networking;
string user = "my email";
string password = "my password";
string combined = user + ":" + password;
UnityWebRequest request = UnityWebRequest.Get("https://1fichier.com/?cs6czd22c8odod74dal2&auth=1");
request.SetRequestHeader("Authorization","Basic " + combined);
yield return request.SendWebRequest();
if(request.isHttpError)
{
Debug.Log(request.error);
}
else
{
if (request.isDone)
{
Debug.Log("Done");
}
}
The base64 encoded :
using UnityEngine.Networking;
string user = "my email";
string password = "my password";
string base64User = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(user));
string base64pass = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(password));
string combined = base64User + ":" + base64pass;
UnityWebRequest request = UnityWebRequest.Get("https://1fichier.com/?cs6czd22c8odod74dal2&auth=1");
request.SetRequestHeader("Authorization","Basic " + combined);
yield return request.SendWebRequest();
if(request.isHttpError)
{
Debug.Log(request.error);
}
else
{
if (request.isDone)
{
Debug.Log("Done");
}
}