Sming
Sming copied to clipboard
Example with HttpRequestAuth
While upgrading to Sming 3.3.0 my old basic authentication is not supported (ex. using response.authorizationRequired() ) Where can I find en example of how to use it in sming 3.3.0 ?
my old basic authentication is not supported
@icodk Are you using basic authentication with HttpClient (to view protected pages) or with HttpServer ( to protect pages ) ?
Yes exactly. As I described in #585
Yes exactly
Which one - Server or Client?
If you use the client and want to send request to a page protected with basic auth you can do something like this
HttpClient client;
// ...
HttpRequest *request = new HttpRequest(URL(UPDATE_URL));
// ...
HttpBasicAuth* authAdapter = new HttpBasicAuth("username","passw0rd");
request->setAuth(authAdapter);
// ...
client.send(request);
No,I want to protect a server page.
Once version 3.4.0 is released I can think about refactoring the auth adapters to work for both http clients and servers.
+1
@icodk: i had the same problem with response.badRequest() I solved it by setting response.code = HTTP_STATUS_BAD_REQUEST as described for forbidden and notFound in HttpResponse.h You sould be fine by replacing "response.authorizationRequired()" by response.code = HTTP_STATUS_UNAUTHORIZED
@jochenjagers Thanks Will try it out