<div dir="ltr">Hi Stian,<div><br></div><div>I&#39;m sorry for the lack of information. Yes you are right I was talking about a packaged/installed app and yes it is Cordova.</div><div><br></div><div><br></div><div><span style="font-family:arial,sans-serif;font-size:13px">* Use a child window to open the login form (our not yet released Cordova/PhoneGap adapter will use this approach)</span><br>
</div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div>If I open a child window for the login form I will need a callback page/script hosted on the server to process the response back from keycloak, right? could you give me some ideas on how to handle this?</div>
<div><br></div><div>Thanks again,</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Mar 17, 2014 at 5:24 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">Hi,<br>
<br>
Are you referring to a packaged html5 based app for smarthpones (and not one that is access through the smartphones browser)?<br>
<br>
There are several ways available to use Keycloak from a packaged/installed app:<br>
<br>
* Register a custom URI schema for the application (something like myapp://oauth-callback) - recommended for a native app (our not yet released iOS and Android adapters will use this approach)<br>
* Start a temporary web server on <a href="http://localhost" target="_blank">http://localhost</a> on any available port - installed app on a desktop (our cli example uses this approach)<br>
* Use a child window to open the login form (our not yet released Cordova/PhoneGap adapter will use this approach)<br>
<br>
If you are using PhoneGap/Cordova the adapter should be ready soon. It won&#39;t be &quot;released&quot; until early May, but will also work with alpha3. If you&#39;re using another technology for your packaged html5 apps, let me know what you&#39;re using and I can give you some hints (it should just require a few minor changes to the PhoneGap/Cordova adapter).<br>

<div class="im HOEnZb"><br>
----- Original Message -----<br>
&gt; From: &quot;Rodrigo Del Canto&quot; &lt;<a href="mailto:delkant@gmail.com">delkant@gmail.com</a>&gt;<br>
</div><div class="HOEnZb"><div class="h5">&gt; To: &quot;Stian Thorgersen&quot; &lt;<a href="mailto:stian@redhat.com">stian@redhat.com</a>&gt;<br>
&gt; Cc: <a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
&gt; Sent: Sunday, 16 March, 2014 8:09:38 AM<br>
&gt; Subject: Re: [keycloak-user] External JS AJAX client for jax-rs backend API<br>
&gt;<br>
&gt; Hello Stian,<br>
&gt;<br>
&gt; I was testing this today. My problem is that the keycloak.js script assumes<br>
&gt;  that the client application is hosted in a app/web server. I&#39;m trying to<br>
&gt; build a html 5 based app for smartphones. So there is no way to use the<br>
&gt; redirect functionality, I need a way to provide to keycloak a username and<br>
&gt; password and receive as response the token id.<br>
&gt;<br>
&gt; Do you think that is possible? Is there any example available.<br>
&gt;<br>
&gt; Thanks.<br>
&gt;<br>
&gt;<br>
&gt; On Mon, Mar 10, 2014 at 10:34 AM, Stian Thorgersen &lt;<a href="mailto:stian@redhat.com">stian@redhat.com</a>&gt; wrote:<br>
&gt;<br>
&gt; &gt; Hi,<br>
&gt; &gt;<br>
&gt; &gt; We have a JS library, it&#39;s available at<br>
&gt; &gt; <a href="http://localhost:8080/js/keycloak.js" target="_blank">http://localhost:8080/js/keycloak.js</a>. There&#39;s no documentation for it<br>
&gt; &gt; yet, and the example needs a bit of TLC, but the example is customer-app-js<br>
&gt; &gt; and will be included in the alpha3 downloads that is due this week.<br>
&gt; &gt;<br>
&gt; &gt; A quick overview to get you started:<br>
&gt; &gt;<br>
&gt; &gt; Keycloak constructor takes a single object with the following properties:<br>
&gt; &gt;<br>
&gt; &gt; * client_id (required) - the name of the application/client in the admin<br>
&gt; &gt; console<br>
&gt; &gt; * client_secret (optional) - not recommended, instead select public client<br>
&gt; &gt; option for your application/client in the admin console<br>
&gt; &gt; * realm (required)<br>
&gt; &gt; * url (optional) - the base url of the server, if not specified it will<br>
&gt; &gt; infer it from the url of the keycloak.js script<br>
&gt; &gt; * onload (optional) - valid options: login-required, check-sso. Login<br>
&gt; &gt; required will redirect to login form when init is called. Check-sso will<br>
&gt; &gt; also redirect to login form, but won&#39;t display login form (used to check if<br>
&gt; &gt; user is logged into to sso realm)<br>
&gt; &gt;<br>
&gt; &gt; For example:<br>
&gt; &gt;<br>
&gt; &gt;   var keycloak = Keycloak({ client_id: &#39;myapp&#39;, realm: &#39;myrealm&#39; })<br>
&gt; &gt;   keycloak.init(function() { alert(&#39;authenticated&#39;) }, function() {<br>
&gt; &gt; alert(&#39;auth failed&#39;) } );<br>
&gt; &gt;<br>
&gt; &gt; Addition methods:<br>
&gt; &gt;<br>
&gt; &gt; * login - redirect to login form<br>
&gt; &gt; * logout - log out<br>
&gt; &gt; * hasRealmRole(role) - returns true if user has the realm role<br>
&gt; &gt; * hasResourceRole(role, resource) - return true if user has the role for<br>
&gt; &gt; the specified resource (application)<br>
&gt; &gt; * loadUserProfile(success, failure) - loads the profile (in the future<br>
&gt; &gt; profile will be retrieved with IDToken from OpenID Connect spec, so this<br>
&gt; &gt; will probably not be required)<br>
&gt; &gt; * onValidAccessToken(success, failure) - invoke methods with a valid<br>
&gt; &gt; token. If the token is expired the refresh token is used to retrieve a new<br>
&gt; &gt; token before invoking the success callback<br>
&gt; &gt;<br>
&gt; &gt; Once authenticated the following properties are available as well:<br>
&gt; &gt;<br>
&gt; &gt; * token - base64 encoded token (use this as the value for the<br>
&gt; &gt; &#39;Authorization&#39; header, for example<br>
&gt; &gt; &quot;xMLHttpRequest.setRequestHeader(&#39;Authorization&#39;, &#39;Bearer &#39; +<br>
&gt; &gt; keycloak.token)&quot;)<br>
&gt; &gt; * tokenParsed - parsed token<br>
&gt; &gt; * authenticated - true if authenticated, false otherwise<br>
&gt; &gt; * subject - userId<br>
&gt; &gt;<br>
&gt; &gt; Please let me know how you get on with it, any feedback would be<br>
&gt; &gt; appreciated.<br>
&gt; &gt;<br>
&gt; &gt; Cheers,<br>
&gt; &gt; Stian<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; ----- Original Message -----<br>
&gt; &gt; &gt; From: &quot;Rodrigo Del Canto&quot; &lt;<a href="mailto:delkant@gmail.com">delkant@gmail.com</a>&gt;<br>
&gt; &gt; &gt; To: <a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
&gt; &gt; &gt; Sent: Saturday, 8 March, 2014 5:54:44 AM<br>
&gt; &gt; &gt; Subject: [keycloak-user] External JS AJAX client for jax-rs backend API<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Hello guys,<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Congrats on the release of project! I think this is the most useful<br>
&gt; &gt; project<br>
&gt; &gt; &gt; for developers in the whole history of internet :D<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; I would like to know if you have any example on how to perform a login<br>
&gt; &gt; from<br>
&gt; &gt; &gt; an external JavaScript client?<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; How would you recommend to do this. I heard you have a JS/jQuery lib to<br>
&gt; &gt; do<br>
&gt; &gt; &gt; this, where can it be found?<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Thanks,<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; delkant<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; _______________________________________________<br>
&gt; &gt; &gt; keycloak-user mailing list<br>
&gt; &gt; &gt; <a href="mailto:keycloak-user@lists.jboss.org">keycloak-user@lists.jboss.org</a><br>
&gt; &gt; &gt; <a href="https://lists.jboss.org/mailman/listinfo/keycloak-user" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a><br>
&gt; &gt;<br>
&gt;<br>
</div></div></blockquote></div><br></div>