Fix Twitter for localhost

This commit is contained in:
Stian Thorgersen 2014-05-21 08:47:58 +01:00
parent ab85f09608
commit c2075af7f7
3 changed files with 5 additions and 6 deletions

View file

@ -33,8 +33,6 @@
<para>
Twitter doesn't allow <literal>localhost</literal> in the redirect URI. To test on a local server
replace <literal>localhost</literal> with <literal>127.0.0.1</literal>.
Twitter also restricts connection to TLS/SSL connections only, so you are required to use HTTPS to access
Keycloak to enable log in with Twitter.
</para>
</tip>
</section>

View file

@ -186,6 +186,10 @@ ol#kc-totp-settings li:first-of-type {
width: 125px;
}
.zocial:hover {
color: #fff !important;
}
.zocial.facebook,
.zocial.github,
.zocial.google,

View file

@ -48,10 +48,7 @@ public class TwitterProvider implements SocialProvider {
Twitter twitter = new TwitterFactory().getInstance();
twitter.setOAuthConsumer(config.getKey(), config.getSecret());
String redirectUri = config.getCallbackUrl();
redirectUri = redirectUri.replace("//localhost", "//127.0.0.1");
RequestToken requestToken = twitter.getOAuthRequestToken(redirectUri);
RequestToken requestToken = twitter.getOAuthRequestToken(config.getCallbackUrl());
return AuthRequest.create(requestToken.getToken(), requestToken.getAuthenticationURL())
.setAttribute("token", requestToken.getToken()).setAttribute("tokenSecret", requestToken.getTokenSecret())