I am trying to add my bearer token in the RequestSpecBuilder
where my specbuilder
looks like
public static RequestSpecification requestSpecBuilderWithAuthorization(String baseURL, AuthenticationScheme auth) {
RequestSpecification req = new RequestSpecBuilder().setBaseUri(baseURL)
.setContentType(ContentType.JSON).setAccept("*/*")
.setAuth(auth)
.build();
return req;
}
And let say I have a bearer token as "bearer ". So my main objective here is to pass bearer token in RequestSpecification
.
So how can I pass this token as a AuthenticationScheme
in setAuth(
) or is it even possible to parameterised a specBuilder
where I can pass bearer token.
You should put your token in header.
req.header("Authorization", "Bearer <your_token_here>");