Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Basic Auth with RestyGWT Rest Services?

How can I set the Basic Auth user id and password when using a RestyGWT Rest Services?

The RestyGWT User Guide describes how to set the user id and password used in basic authentication for the RestyGWT REST API but I haven't found any docs describing how to do basic auth with the RestyGWT Rest Services

I'm using RestyGWT v1.2

***** UPDATE ******* I tried the following with no luck. The browser is still opening a prompt for User ID / Password when I call the service method.

final Map<String, String> headers = new HashMap<String, String>();
headers.put("Authorization", "Basic anJvYmPpbnKAbGl4ZXByb2N4c3OuZ29tOmpyb2JiaW6z");
final Resource workflowResource = new Resource("", headers);
((RestServiceProxy)workflowService).setResource(workflowResource);
like image 864
Justin Avatar asked Jun 19 '26 01:06

Justin


1 Answers

I think the code example provided in the question should work. I found another person experiencing problems adding a custom header to a RestyGWT service as described in this post to the RestyGWT group and this bug in Github.

As a temporary workaround, I'm using the @HeaderParam and passing the Base64 encoded Authorization header through the RestService method call.

public void getRestData(@HeaderParam("Authorization") String authHeader, MethodCallback<List<Workflow>> callback);
like image 175
Justin Avatar answered Jun 20 '26 15:06

Justin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!