jwagenleitner / groovy-wslite

Lightweight SOAP and REST webservice clients for Groovy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OAuth Support

restagner opened this issue · comments

Does groovy-wslite support OAuth?

No support built in.

Ok. You mention that no support is built in, which leads to ask if something like SignPost (https://github.com/mttkay/signpost) could work with groovy-wslite. Or, possibly some other OAuth framework .. in your mind, is that even feasible?

It looks like it would be feasible to use signpost since it works with an HttpURLConnection. A custom HTTPAuthorization can be passed to the client and it'll be called with the connection before the request is sent.

I have not tested this but something along the following lines might work:

OAuthConsumer consumer = .... // set up the signpost consumer

def client = new RESTClient("http://api.example.com/protected")

client.authorization = { HttpURLConnection connection -> 
    consumer.sign(connection)
} // as wslite.http.auth.HTTPAuthorization

def response = client.get .....