<div dir="ltr">I&#39;m testing my UI using GWTs Super Dev Mode, which means its origin is set to <a href="http://127.0.0.1:8888">http://127.0.0.1:8888</a>.    Keycloak runs on <a href="http://127.0.0.1:8080/auth">http://127.0.0.1:8080/auth</a>.</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 2, 2014 at 7:32 AM, Stian Thorgersen <span dir="ltr">&lt;<a href="mailto:stian@redhat.com" target="_blank">stian@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">It&#39;s the correct approach to add the preflight. Please send a PR and we&#39;ll merge it.<br>
<br>
Out of curiosity do you know why it&#39;s sending a preflight in your app? It doesn&#39;t when I test it out here, which AFAIK is correct according to spec (content-type is application/x-www-form-urlencoded and there&#39;s no custom headers set).<br>
<span class=""><br>
----- Original Message -----<br>
&gt; From: &quot;Alain Penders&quot; &lt;<a href="mailto:alain@rexorient.com">alain@rexorient.com</a>&gt;<br>
</span><div><div class="h5">&gt; To: <a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a><br>
&gt; Sent: Tuesday, 2 December, 2014 3:04:50 PM<br>
&gt; Subject: [keycloak-dev] Fwd: Preflight for token refresh<br>
&gt;<br>
&gt; Hi all,<br>
&gt;<br>
&gt; I&#39;m building a new app using GWT 2.7 using the Keycloak javascript adapter<br>
&gt; and GWT jsInterop. This works extremely well.<br>
&gt;<br>
&gt; The problem I ran into is if I walk away for 5 minutes and then try to do<br>
&gt; something, the token refresh fails on preflight. As shown in the<br>
&gt; documentation, I call keycloak.updateToken(30) to refresh the base token in<br>
&gt; case it has expired. Since in this case it has indeed expired, keycloak<br>
&gt; makes a call to /auth/realms/&lt;myrealm&gt;/tokens/refresh. The OPTIONS call to<br>
&gt; this location doesn&#39;t contain the Accept headers, and my app ends up dead in<br>
&gt; the water.<br>
&gt;<br>
&gt; To fix this, I added the following code to OpenIDConnectService:<br>
&gt;<br>
&gt; /**<br>
&gt; * CORS preflight path for refresh token requests<br>
&gt; *<br>
&gt; * @return<br>
&gt; */<br>
&gt; @Path(&quot;refresh&quot;)<br>
&gt; @OPTIONS<br>
&gt; @Produces(MediaType.APPLICATION_JSON)<br>
&gt; public Response refreshAccessTokenPreflight() {<br>
&gt; if (logger.isDebugEnabled()) {<br>
&gt; logger.debugv(&quot;cors request from: {0}&quot;,<br>
&gt; request.getHttpHeaders().getRequestHeaders().getFirst(&quot;Origin&quot;));<br>
&gt; }<br>
&gt; return Cors.add(request, Response.ok()).auth().preflight().build();<br>
&gt; }<br>
&gt;<br>
&gt; If this wasn&#39;t the correct solution for my problem, I&#39;d enjoy hearing where I<br>
&gt; went wrong.<br>
&gt;<br>
&gt; Thanks,<br>
&gt; Alain<br>
&gt;<br>
&gt;<br>
</div></div>&gt; _______________________________________________<br>
&gt; keycloak-dev mailing list<br>
&gt; <a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/keycloak-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-dev</a><br>
</blockquote></div><br></div>