-
Notifications
You must be signed in to change notification settings - Fork 66
authenticate does not work #7
Comments
Do you have an example where it doesn't work? |
Hi @beders, I'm using Resty 0.3.1, and I can't seem to get HTTP Basic Authentication to work. I receive an error when I use the
I'm new to Java, so I could be completely wrong, but I noticed that there's a reference to the method To work around this bug, I'm using the Resty resty = new Resty();
String encodedString = Base64.encodeToString((username + ":" + password).getBytes("UTF-8"), android.util.Base64.DEFAULT);
resty.alwaysSend("Authorization", "Basic " + encodedString);
Object name = resty.json(baseURI + "/users/new").get("user.firstName");
System.out.println(name); Thanks for this library! |
Thank you for trying Resty. The problem is that sometimes the request URL for an authentication is null, which is unexpected. Thank you so much for sharing your work-around! Cheers, On Feb 27, 2012, at 1:54 PM, Todd Mazierski wrote:
|
Todd, what version of Java are you using?
On Feb 27, 2012, at 1:54 PM, Todd Mazierski wrote:
|
… not delivering requestingURL to the Authenticator class (fix for issue #7)
The current head version has a new call Resty.authenticateForRealm On Feb 27, 2012, at 1:54 PM, Todd Mazierski wrote:
|
I'm also having problems with the authentication. But with my case for some reason I'm always getting the 401 unauthorized error. I believe there is something wrong with setting the parameters for username and password. I am absolutely sure the credentials I set are correct and I verified this by using Poster plugin in the Chrome browser. below is the code that i am using... resty.authenticate("http://localhost/drupal/rest-api/user/login", "ecxxxx", "xxxx".toCharArray()); resty.json("http://localhost/drupal/rest-api/user/login.json"); And below is the error output. java.io.IOException: Server returned HTTP response code: 401 for URL: http://localhost/drupal/rest-api/user/login.json at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1436) at us.monoid.web.AbstractResource.fill(AbstractResource.java:34) at us.monoid.web.Resty.fillResourceFromURL(Resty.java:417) at us.monoid.web.Resty.doPOSTOrPUT(Resty.java:379) at us.monoid.web.Resty.json(Resty.java:208) at us.monoid.web.Resty.json(Resty.java:213) at MassimoDuttiItem.saveResty(MassimoDuttiItem.java:56) at EmParisParser.main(EmParisParser.java:43) I also tried setting the form values like so ... resty.json("http://localhost/drupal/rest-api/user/login", Resty.form(Resty.data("username", "ecdiddy"))); and receive the same error. I checked my server logs and my login module doesn't recognize the username that was set. It thinks it is accessing as an anonymous user. That is why I believe there is something wrong with the setting form parameters with this resty function. I'm not sure if authenticateForRealm is the solution for this issue which mentions about not delivering the URL. Is anyone else facing this issue? |
I have the same problem as ecdiddy re: authenticate() not working. Maybe the author could provide an example and some more explanation in the documentation? I'm doing HTTPS, as will most real-world users wanting to authenticate. Non-Android version of Todd's solution: |
Seeing this issue as well, appears that not authentication is being attempted. |
authenticate method is not working. There doesn't seem to be a testcase for authenticate.
The text was updated successfully, but these errors were encountered: