Non riesco a capire come passare una schifosissima autenticazione nella cartella di un server..
Questo sono il codice e l'errore. Se vado tramite url funziona tutto bene. Un aiuto?
B4X:
Sub prova
Dim j As HttpJob
j.Initialize("",Me)
j.Password = "user"
j.Username ="psw"
j.Download("miodominio/user_backup/FIRST.png")
'j.GetRequest.SetHeader("Authorization","Basic") 'provato anche con questo
Wait For (j) JobDone(j As HttpJob)
LogColor(j.Success,Colors.Blue)
End Sub
B4X:
ResponseError. Reason: Unauthorized, Response: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>401 Unauthorized</title>
</head><body>
<h1>Unauthorized</h1>
<p>This server could not verify that you
are authorized to access the document
requested. Either you supplied the wrong
credentials (e.g., bad password), or your
browser doesn't understand how to supply
the credentials required.</p>
</body></html>
Non ho con me il mio PC, ma prova a dare un'occhiata al demo di AppUpdating. Se non ricordo male, avevo "protetto" i dati con il sistema .htaccess e quindi il codice che accede al nuovo apk dovrebbe mostrare come passare le credenziali di autenticazione. Ci dovrebbe essere qualcosa anche nei primi post, credo.
Grazie @udg, ho dato un occhiata, ma anche tu utilizzi password e username come me.. non capisco dove sia il problema, alla fine sono riuscito a risolvere, ma è molto strano come cosa..
B4X:
j.Initialize("",Me)
Dim su As StringUtils
Dim auth As String = su.EncodeBase64("user:password".GetBytes("UTF8"))
j.Download("domain/user_backup/FIRST.png")
j.GetRequest.SetHeader("Authorization","Basic "&auth)