Search code examples
restgwtresty-gwt

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);

Solution

  • 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);