tyazid / RTSP-Java-UrlConnection

Full java Implemetation of RTSP (RFC 2326) command protocol.
Apache License 2.0
33 stars 13 forks source link

Connexion en :Authorization Basic #1

Open marcosemiao opened 8 years ago

marcosemiao commented 8 years ago

J'ai l'impression que Autorisation n'est pas donnée à la requête, j'obtiens un message d'erreur :

[CONNECTION.DUMPING] .... RECEIVEING: TSP/1.0 401 Unauthorized

String userPassword = username + ":" + password;
Encoder encoder = Base64.getEncoder();
String encodeToString = encoder.encodeToString(userPassword.getBytes());
yc.setRequestProperty("Authorization", "Basic " + encodeToString);

Ou il faut faire d'une autre façon ?

Merci d'avance et merci pour cette librairie ;)

willagner commented 7 years ago

I have this problem to...

You can solve this?

tyazid commented 7 years ago

Hi and sorry for the delay (a little too busy!), plz try with something like this (assuming username & password are provided):

String b64 = Base64.getEncoder().encodeToString(username.concat(":").concat(password).getBytes(Charset.defaultCharset()));

final RtspURLConnection urlc = (RtspURLConnection) url.openConnection();
FieldAttributes attrib = new FieldAttributes();
attrib.addField("Authorization", "Basic ".concat(b64));
urlc.setDescribeAttributes(attrib); // set before call connect method
urlc.connect();

Regards.