}
@Test
public void stateParam() throws Exception {
String accessTokenRedirectUri = startAuthorizationCallbackServer(clientId, secret);
WebDriver webdriver = getWebDriver();
/*
The RFC says (http://tools.ietf.org/html/rfc6749#appendix-A.5):
state = 1*VSCHAR
Defined in http://tools.ietf.org/html/rfc6749#appendix-A:
VSCHAR = %x20-7E
The variable 'state' below contains all chars in 0x20-0x7E
*/
String state = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmno0070pqrstuvwxyz{|}~";
String url = String.format(
"%s/oauth2/authorize?response_type=%s&scope=%s&client_id=%s&redirect_uri=%s&state=%s",
baseUrl(), "code", "read,write", clientId,
URLEncoder.encode(accessTokenRedirectUri, "UTF-8"),
URLEncoder.encode(state, "UTF-8"));
webdriver.get(url);
login(webdriver,false);
// wait for token response to arrive, therefore block
getAuthorizationCodeRequestHandler().getTokenResponseBlocking();