Open GoogleCodeExporter opened 9 years ago
Could you provide a pull request this?
Original comment by johan.ha...@gmail.com
on 15 Sep 2014 at 12:08
Johan, do you mean a fix for that or complete steps to reproduce?
Original comment by mgawine...@gmail.com
on 15 Sep 2014 at 12:10
Sorry I thought you were familiar with pull requests. A pull request is githubs
way of providing a patch (only better :)). See
https://help.github.com/articles/using-pull-requests. It would be great if you
could help out and solve this using a pull request. It will (hopefully) be
easier for you to fix it since you have everything fresh in memory. I'd be
happy to include the fix in the next release.
Original comment by johan.ha...@gmail.com
on 15 Sep 2014 at 12:26
I'd really like to fix this but I'm not sure how to. Should I get the query
string from OAuth20ServiceImpl and convert it to headers?!
Original comment by johan.ha...@gmail.com
on 23 Sep 2014 at 9:01
Seems to me like Scribe only provides URL signatures and doesn't support
headers?
Original comment by johan.ha...@gmail.com
on 23 Sep 2014 at 9:06
OAuth2 (RFC6750) provides 3 ways to sign a request with an access token: in
query string, in Authorization header, and in form. Seems like a Scribe is
supporting only the first one.
So instead of Scribe I started to use my own Filter implementations, each
signing request in one of the ways above.
I can see a few solutions:
(a) file a bug/feature request to Scribe and write test in RestAssured for that
(b) implement a workaround to copies token from query string param to
Authorization header
(c) stop using Scribe for OAuth2 and use other library (Spring Security?) or
own implementation
We in the project decided for the solution (c) as Scribe has other limitations
in context of OAuth2, like it does not support fetching token from the
authorization server. We wrote that part ourselves as well.
Original comment by mgawine...@gmail.com
on 23 Sep 2014 at 9:35
I run into the same problem -
http://stackoverflow.com/questions/29155161/restassured-oauth2-http-status-code-
401
Is there some kind of workaround based on Restassured library in order to avoid
this issue ? I really don't want to rewrite all my tests on some other lib.
Original comment by Alexande...@gmail.com
on 20 Mar 2015 at 8:11
Alex: Sorry I don't know of any workaround but please share it if you find one.
@mgawinecki: I'm completely missed your comment. Would it be possible for you
to share your filter with us? If possible I'd like to include it in REST
Assured.
Original comment by johan.ha...@gmail.com
on 20 Mar 2015 at 10:32
Johan,
Here's a method to create a filter:
public static Filter sign(final String accessToken) {
return new Filter() {
@Override
public Response filter(FilterableRequestSpecification requestSpec,
FilterableResponseSpecification responseSpec,
FilterContext ctx) {
requestSpec.header("Authorization", String.format("Bearer %s",
accessToken));
return ctx.next(requestSpec, responseSpec);
}
};
}
Assumption is you already obtained an access token in one of the
authorization grants flows. Obviously, you may want to turn anonymous
filter class into a named class.
Here's example of use:
given().
log().all().
baseUri(host).
filter(sign(accessToken)).
when().
get("/some-endpoint/do-sth").
then().
log().all().
statusCode(200);
Nothing really complex.
HTH,
Maciej
2015-03-20 11:32 GMT+01:00 <rest-assured@googlecode.com>:
Original comment by mgawine...@gmail.com
on 23 Mar 2015 at 9:05
Original issue reported on code.google.com by
mgawine...@gmail.com
on 11 Sep 2014 at 3:32