<div dir="ltr">Correct me if I am wrong, but the last time I looked at the Facebook button that appears on the login page, it was just a simple link to facebook with some parameters like the state.<br></div><div class="gmail_extra"><br><div class="gmail_quote">2014-12-03 12:31 GMT+01:00 Stian Thorgersen <span dir="ltr">&lt;<a href="mailto:stian@redhat.com" target="_blank">stian@redhat.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Just thought of a reason why it won&#39;t work. The link to login with Facebook is to the Keycloak server, which then sets the required state before redirecting to Facebook.<br>
<span class="im HOEnZb"><br>
----- Original Message -----<br>
&gt; From: &quot;Stian Thorgersen&quot; &lt;<a href="mailto:stian@redhat.com">stian@redhat.com</a>&gt;<br>
&gt; To: &quot;Christian Beikov&quot; &lt;<a href="mailto:christian.beikov@gmail.com">christian.beikov@gmail.com</a>&gt;<br>
&gt; Cc: <a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a><br>
</span><div class="HOEnZb"><div class="h5">&gt; Sent: Wednesday, 3 December, 2014 12:30:03 PM<br>
&gt; Subject: Re: [keycloak-dev] Login with Access Token<br>
&gt;<br>
&gt; The callback to Keycloak expects a code, not a token, so I don&#39;t think it<br>
&gt; would work unless you modify Keycloak&#39;s Facebook provider. I can&#39;t think of<br>
&gt; any other reasons why it wouldn&#39;t work.<br>
&gt;<br>
&gt; ----- Original Message -----<br>
&gt; &gt; From: &quot;Christian Beikov&quot; &lt;<a href="mailto:christian.beikov@gmail.com">christian.beikov@gmail.com</a>&gt;<br>
&gt; &gt; To: &quot;Stian Thorgersen&quot; &lt;<a href="mailto:stian@redhat.com">stian@redhat.com</a>&gt;<br>
&gt; &gt; Cc: <a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a><br>
&gt; &gt; Sent: Wednesday, 3 December, 2014 11:04:05 AM<br>
&gt; &gt; Subject: Re: [keycloak-dev] Login with Access Token<br>
&gt; &gt;<br>
&gt; &gt; I was thinking of something like the following as a workaround<br>
&gt; &gt;<br>
&gt; &gt; 1. Create a hidden iframe in a webview that navigates to the login page of<br>
&gt; &gt; the keycloak server.<br>
&gt; &gt; 2. Extract the state from the link of the Facebook login<br>
&gt; &gt; 3. Start the login with the native SDK<br>
&gt; &gt; 4. On success navigate in the iframe to the social callback<br>
&gt; &gt; 5. Use some keycloak token to act as the logged in user<br>
&gt; &gt;<br>
&gt; &gt; Regarding 4. I am not sure what URL I should invoke exactly. I guess I have<br>
&gt; &gt; to append the state parameter to it, but I couldn&#39;t find out exactly and I<br>
&gt; &gt; haven&#39;t debugged that far yet.<br>
&gt; &gt; Regarding 5. I don&#39;t know how to retrieve that keycloak token from the<br>
&gt; &gt; iframe, but I hope there is a way.<br>
&gt; &gt;<br>
&gt; &gt; For this to work I will probably have to add some CORS http headers that<br>
&gt; &gt; will allow localhost so that the app can access the iframe. Although this<br>
&gt; &gt; makes it vulnerable, since every localhost app could then &quot;steal&quot; the<br>
&gt; &gt; keycloak token, it would do the job for now.<br>
&gt; &gt;<br>
&gt; &gt; What do you think? Could that work?<br>
&gt; &gt;<br>
&gt; &gt; 2014-12-03 9:43 GMT+01:00 Stian Thorgersen &lt;<a href="mailto:stian@redhat.com">stian@redhat.com</a>&gt;:<br>
&gt; &gt;<br>
&gt; &gt; &gt; Keycloak generates a special state parameter. It consists of two parts, a<br>
&gt; &gt; &gt; signature and an id. The id is used to lookup a session in Keycloak,<br>
&gt; &gt; &gt; while<br>
&gt; &gt; &gt; the signature is then used to verify that specific request is valid (a<br>
&gt; &gt; &gt; session can only be used for one thing at a time, for example a social<br>
&gt; &gt; &gt; login). By design there&#39;s no way you can generate this yourself unless<br>
&gt; &gt; &gt; you<br>
&gt; &gt; &gt; have access to the Keycloak database.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; ----- Original Message -----<br>
&gt; &gt; &gt; &gt; From: &quot;Christian Beikov&quot; &lt;<a href="mailto:christian.beikov@gmail.com">christian.beikov@gmail.com</a>&gt;<br>
&gt; &gt; &gt; &gt; To: &quot;Stian Thorgersen&quot; &lt;<a href="mailto:stian@redhat.com">stian@redhat.com</a>&gt;, <a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a><br>
&gt; &gt; &gt; &gt; Sent: Wednesday, 3 December, 2014 9:33:20 AM<br>
&gt; &gt; &gt; &gt; Subject: Re: [keycloak-dev] Login with Access Token<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; I am wondering how you do that. I know that there is a state parameter<br>
&gt; &gt; &gt; that<br>
&gt; &gt; &gt; &gt; is added to the facebook login url, but I could just make an initial<br>
&gt; &gt; &gt; &gt; request to keycloak to copy that, or did I understand something wrong?<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; 2014-12-03 9:22 GMT+01:00 Stian Thorgersen &lt;<a href="mailto:stian@redhat.com">stian@redhat.com</a>&gt;:<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; It&#39;s code that is currently changing as we&#39;re working on adding<br>
&gt; &gt; &gt; enterprise<br>
&gt; &gt; &gt; &gt; &gt; IdP&#39;s as well as social IdP&#39;s we have at the moment.<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; I think the correct approach would be to use the direct grant api,<br>
&gt; &gt; &gt; which<br>
&gt; &gt; &gt; &gt; &gt; currently lets you exchange a username + password for a Keycloak<br>
&gt; &gt; &gt; token, we<br>
&gt; &gt; &gt; &gt; &gt; could add an option here to pass in a token from an external IdP to<br>
&gt; &gt; &gt; &gt; &gt; exchange for a internal Keycloak token. If you&#39;re interested in<br>
&gt; &gt; &gt; looking at<br>
&gt; &gt; &gt; &gt; &gt; the code look at OpenIDConnectService.grantAccessToken.<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; There&#39;s no work-around that you can do due to security restrictions<br>
&gt; &gt; &gt; &gt; &gt; in<br>
&gt; &gt; &gt; &gt; &gt; Keycloak. Keycloak makes sure that the callback can only be called if<br>
&gt; &gt; &gt; it<br>
&gt; &gt; &gt; &gt; &gt; indeed made the original request.<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; ----- Original Message -----<br>
&gt; &gt; &gt; &gt; &gt; &gt; From: &quot;Christian Beikov&quot; &lt;<a href="mailto:christian.beikov@gmail.com">christian.beikov@gmail.com</a>&gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; To: &quot;Stian Thorgersen&quot; &lt;<a href="mailto:stian@redhat.com">stian@redhat.com</a>&gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; Sent: Wednesday, 3 December, 2014 9:11:55 AM<br>
&gt; &gt; &gt; &gt; &gt; &gt; Subject: Re: [keycloak-dev] Login with Access Token<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; Thanks for the quick answer. Could you maybe give me a hint on how<br>
&gt; &gt; &gt; &gt; &gt; &gt; I<br>
&gt; &gt; &gt; &gt; &gt; could<br>
&gt; &gt; &gt; &gt; &gt; &gt; implement that in a quick-and-dirty way? Could I maybe do some<br>
&gt; &gt; &gt; &gt; &gt; &gt; iframe<br>
&gt; &gt; &gt; &gt; &gt; magic<br>
&gt; &gt; &gt; &gt; &gt; &gt; in a hidden webview to do the login? I am not quite sure how the<br>
&gt; &gt; &gt; social<br>
&gt; &gt; &gt; &gt; &gt; &gt; login works exactly. Facebook will redirect me back to the social<br>
&gt; &gt; &gt; &gt; &gt; callback<br>
&gt; &gt; &gt; &gt; &gt; &gt; address after a login, but how does keycloak actually retrieve that<br>
&gt; &gt; &gt; &gt; &gt; access<br>
&gt; &gt; &gt; &gt; &gt; &gt; token? If I knew that, I could maybe create a workaround for now<br>
&gt; &gt; &gt; &gt; &gt; &gt; and<br>
&gt; &gt; &gt; &gt; &gt; maybe<br>
&gt; &gt; &gt; &gt; &gt; &gt; also contribute something? :)<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; 2014-12-03 8:48 GMT+01:00 Stian Thorgersen &lt;<a href="mailto:stian@redhat.com">stian@redhat.com</a>&gt;:<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; ----- Original Message -----<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; From: &quot;Christian Beikov&quot; &lt;<a href="mailto:christian.beikov@gmail.com">christian.beikov@gmail.com</a>&gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; To: <a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a><br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; Sent: Tuesday, 2 December, 2014 6:58:42 PM<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; Subject: [keycloak-dev] Login with Access Token<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; Hello!<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; I am new to OAuth so sorry if my question is dumb.<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; I have an App which wants to provide a custom and Facebook<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; login.<br>
&gt; &gt; &gt; &gt; &gt; Since<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; many<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; people already have the Facebook App installed, I thought it<br>
&gt; &gt; &gt; might be<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; better<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; to give them the native experience and use the Facebook SDK to<br>
&gt; &gt; &gt; &gt; &gt; implement<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; the<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; login.<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; The problem now is, that I have the Access Token from the<br>
&gt; &gt; &gt; successful<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; Facebook<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; login, but don&#39;t know how to properly login at the Keycloak<br>
&gt; &gt; &gt; server<br>
&gt; &gt; &gt; &gt; &gt; with<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; that.<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; Any ideas on how to do that? Or is that even stupid and is<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; there<br>
&gt; &gt; &gt; a<br>
&gt; &gt; &gt; &gt; &gt; better<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; way?<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; Not at all a dumb question and we actually had someone else ask<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; the<br>
&gt; &gt; &gt; &gt; &gt; same<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; last week.<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; Currently, Keycloak does not support this flow, but it something<br>
&gt; &gt; &gt; we may<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; consider adding.<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; --<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; Mit freundlichen Grüßen,<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; Christian Beikov<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; _______________________________________________<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; keycloak-dev mailing list<br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; <a href="mailto:keycloak-dev@lists.jboss.org">keycloak-dev@lists.jboss.org</a><br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt; &gt; <a href="https://lists.jboss.org/mailman/listinfo/keycloak-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-dev</a><br>
&gt; &gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; --<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; Mit freundlichen Grüßen,<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt; &gt; *Christian Beikov*Blazebit Design &amp; Developing<br>
&gt; &gt; &gt; &gt; &gt; &gt; <a href="http://www.blazebit.com" target="_blank">http://www.blazebit.com</a><br>
&gt; &gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; --<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; Mit freundlichen Grüßen,<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt; *Christian Beikov*Blazebit Design &amp; Developing<br>
&gt; &gt; &gt; &gt; <a href="http://www.blazebit.com" target="_blank">http://www.blazebit.com</a><br>
&gt; &gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; --<br>
&gt; &gt;<br>
&gt; &gt; Mit freundlichen Grüßen,<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; *Christian Beikov*Blazebit Design &amp; Developing<br>
&gt; &gt; <a href="http://www.blazebit.com" target="_blank">http://www.blazebit.com</a><br>
&gt; &gt;<br>
&gt;<br>
&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>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature"><div dir="ltr"><br>Mit freundlichen Grüßen,<br><br><b>Christian Beikov<br></b>Blazebit Design &amp; Developing<br><a href="http://www.blazebit.com" target="_blank">http://www.blazebit.com</a></div></div>
</div>