public void testState() throws MalformedURLException, RequiresHttpAction { BaseOAuth20StateClient client = new FacebookClient(KEY, SECRET); client.setCallbackUrl(CALLBACK_URL); client.setState("OK"); URL url = new URL(client.getRedirectAction(MockWebContext.create()).getLocation()); assertTrue(url.getQuery().contains("state=OK")); }
@Override protected void internalInit(final WebContext context) { super.internalInit(context); CommonHelper.assertNotBlank("fields", this.fields); this.api20 = new ExtendedFacebookApi(); if (StringUtils.isNotBlank(this.scope)) { this.service = new StateOAuth20ServiceImpl( this.api20, new OAuthConfig( this.key, this.secret, computeFinalCallbackUrl(context), SignatureType.Header, this.scope, null), this.connectTimeout, this.readTimeout, this.proxyHost, this.proxyPort); } else { this.service = new StateOAuth20ServiceImpl( this.api20, new OAuthConfig( this.key, this.secret, computeFinalCallbackUrl(context), SignatureType.Header, null, null), this.connectTimeout, this.readTimeout, this.proxyHost, this.proxyPort); } }