You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by Christofer Dutz <ch...@c-ware.de> on 2015/09/11 11:10:53 UTC

StageWebView not able to understand Http 307 Responses?

Hi,


First of all ... this is probably more an AIR question as it is a Flex question, but I am thinking that here eventually someone knows the answer to this question.


I'm struggling to make my Flex-based mobile application use Keycloak as OAuth2 server. So far I got most of it working.


For anyone not familiar with Keycloak. It allows me to: Create a login on Keycloak itself or use an OAuth service such as Github, Google+, Twitter, ...

Whenever a user wants to login, keycloak shows a login screen (HTML Page) with username+password fields as well as buttons for each of the services that are configured. When clicking on "Github" for example, I am redirected to a Github page asking me if I want to grant access to that application. As soon ay I confirm this, I can simply login by clicking on the "Github" button.


I am using a StageWebView for displaying the login screen and am using the Adobe OAuth2 lib described here: http://blogs.adobe.com/charles/2012/05/oauth-2-0-library-for-actionscript.html

OAuth 2.0 Library for ActionScript
Tweet
Weitere Informationen...<http://blogs.adobe.com/charles/2012/05/oauth-2-0-library-for-actionscript.html>



Logging in with username+password works. Klicking on "github" however doesn't. Investigating the communication with Wireshark now revealed that when logging in with username+password a "http 302" response is returned and that works fine. However if clicking on "github" keacloak returns a "http 307" which should be handled slightly different. Unfortunately the StageWebView doesn't react at all on this response.


Is this eventually not implemented? If yes ... is there a workaround or an alternative to the StageWebView?


Chris

AW: StageWebView not able to understand Http 307 Responses?

Posted by Christofer Dutz <ch...@c-ware.de>.
Currently accessing Keycloak is a mix of StageWebView and URLLoader. 
The StageWebView is needed for the "Human interaction" and the URLLoader for the data-extraction.
Now it seems that keacloak relys on cookies being set in the "human interaction" part, that are then sent during the URLLoader part to get the token object. Unfortunately this cookie sharing doesn't seem to work reliably. Especially if I got this working on Desktop, it doesn't mean that this will work on Android or iOS :-( (See https://helpx.adobe.com/de/air/kb/stagewebview-differences-platforms-air-sdk.html)

I am therefore dropping the StageWebView option and creating a html-parser that extracts information from the login-page sent by keycloak. Trying to replicate the functionality in the application itself.

Seems I have stumbled in one part that is not handled very satisfactory in Air :-(

Chris

________________________________________
Von: Harbs <ha...@gmail.com>
Gesendet: Freitag, 11. September 2015 13:07
An: users@flex.apache.org
Betreff: Re: StageWebView not able to understand Http 307 Responses?

Did you try using URLLoader to get the response codes and respond as needed? (I’m not that familiar with StageWebView, but I imagine there’s a way to intercept the request.)

I’ve needed to respond to specific response codes and I use this pattern:
                        if(loader == null){
                                loader = new URLLoader();
                                configureListeners(loader);
                        }


                private function configureListeners(dispatcher:IEventDispatcher):void {
                        dispatcher.addEventListener(Event.COMPLETE, completeHandler);
                        dispatcher.addEventListener(Event.OPEN, openHandler);
                        dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
                        dispatcher.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
//                      dispatcher.addEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS,httpResponseStatusHandler);// AIR ONLY
                        dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
                }
                private function httpStatusHandler(ev:HTTPStatusEvent):void{
                        //trace (ev);
                        status  = String(ev.status);
                }

                private function completeHandler(ev:Event):void{
                        var eventType:String;
                        bytes = loader.data as ByteArray;
                        var responseData:XML;
                        switch(status){
                                case  "200":
                                        // do something

                                        break;
                                case  "202":
                                        // do something else
                                        break;
                        }
                }

Harbs

On Sep 11, 2015, at 1:52 PM, Christofer Dutz <ch...@c-ware.de> wrote:

> Hi Maxim,
>
> the problem is not authenticating against G+ from mobile, but authenticating against G+ using Keycloak. It's sort of a OAuth proxy you can use. It seems that this returns Http 307 responses for redirecting to the individual login pages.
>
> Chris
>
> ________________________________________
> Von: Maxim Solodovnik <so...@gmail.com>
> Gesendet: Freitag, 11. September 2015 11:24
> An: users@flex.apache.org
> Betreff: Re: StageWebView not able to understand Http 307 Responses?
>
> Hello Chris,
>
> I was able to auth against G+ using this code:
> http://stackoverflow.com/questions/10717919/how-to-integrate-google-in-a-flex-mobile-application
> (slightly modified)
>
> On Fri, Sep 11, 2015 at 3:10 PM, Christofer Dutz <ch...@c-ware.de>
> wrote:
>
>> Hi,
>>
>>
>> First of all ... this is probably more an AIR question as it is a Flex
>> question, but I am thinking that here eventually someone knows the answer
>> to this question.
>>
>>
>> I'm struggling to make my Flex-based mobile application use Keycloak as
>> OAuth2 server. So far I got most of it working.
>>
>>
>> For anyone not familiar with Keycloak. It allows me to: Create a login on
>> Keycloak itself or use an OAuth service such as Github, Google+, Twitter,
>> ...
>>
>> Whenever a user wants to login, keycloak shows a login screen (HTML Page)
>> with username+password fields as well as buttons for each of the services
>> that are configured. When clicking on "Github" for example, I am redirected
>> to a Github page asking me if I want to grant access to that application.
>> As soon ay I confirm this, I can simply login by clicking on the "Github"
>> button.
>>
>>
>> I am using a StageWebView for displaying the login screen and am using the
>> Adobe OAuth2 lib described here:
>> http://blogs.adobe.com/charles/2012/05/oauth-2-0-library-for-actionscript.html
>>
>> OAuth 2.0 Library for ActionScript
>> Tweet
>> Weitere Informationen...<
>> http://blogs.adobe.com/charles/2012/05/oauth-2-0-library-for-actionscript.html
>>>
>>
>>
>>
>> Logging in with username+password works. Klicking on "github" however
>> doesn't. Investigating the communication with Wireshark now revealed that
>> when logging in with username+password a "http 302" response is returned
>> and that works fine. However if clicking on "github" keacloak returns a
>> "http 307" which should be handled slightly different. Unfortunately the
>> StageWebView doesn't react at all on this response.
>>
>>
>> Is this eventually not implemented? If yes ... is there a workaround or an
>> alternative to the StageWebView?
>>
>>
>> Chris
>>
>
>
>
> --
> WBR
> Maxim aka solomax

Re: StageWebView not able to understand Http 307 Responses?

Posted by Harbs <ha...@gmail.com>.
Did you try using URLLoader to get the response codes and respond as needed? (I’m not that familiar with StageWebView, but I imagine there’s a way to intercept the request.)

I’ve needed to respond to specific response codes and I use this pattern:
			if(loader == null){
				loader = new URLLoader();
				configureListeners(loader);
			}


		private function configureListeners(dispatcher:IEventDispatcher):void {
			dispatcher.addEventListener(Event.COMPLETE, completeHandler);
			dispatcher.addEventListener(Event.OPEN, openHandler);
			dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
			dispatcher.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
//			dispatcher.addEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS,httpResponseStatusHandler);// AIR ONLY
			dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
		}
		private function httpStatusHandler(ev:HTTPStatusEvent):void{
			//trace (ev);
			status  = String(ev.status);
		}

		private function completeHandler(ev:Event):void{
			var eventType:String;
			bytes = loader.data as ByteArray;
			var responseData:XML;
			switch(status){
				case  "200":
					// do something

					break;
				case  "202":
					// do something else
					break;
			}
		}

Harbs

On Sep 11, 2015, at 1:52 PM, Christofer Dutz <ch...@c-ware.de> wrote:

> Hi Maxim, 
> 
> the problem is not authenticating against G+ from mobile, but authenticating against G+ using Keycloak. It's sort of a OAuth proxy you can use. It seems that this returns Http 307 responses for redirecting to the individual login pages. 
> 
> Chris
> 
> ________________________________________
> Von: Maxim Solodovnik <so...@gmail.com>
> Gesendet: Freitag, 11. September 2015 11:24
> An: users@flex.apache.org
> Betreff: Re: StageWebView not able to understand Http 307 Responses?
> 
> Hello Chris,
> 
> I was able to auth against G+ using this code:
> http://stackoverflow.com/questions/10717919/how-to-integrate-google-in-a-flex-mobile-application
> (slightly modified)
> 
> On Fri, Sep 11, 2015 at 3:10 PM, Christofer Dutz <ch...@c-ware.de>
> wrote:
> 
>> Hi,
>> 
>> 
>> First of all ... this is probably more an AIR question as it is a Flex
>> question, but I am thinking that here eventually someone knows the answer
>> to this question.
>> 
>> 
>> I'm struggling to make my Flex-based mobile application use Keycloak as
>> OAuth2 server. So far I got most of it working.
>> 
>> 
>> For anyone not familiar with Keycloak. It allows me to: Create a login on
>> Keycloak itself or use an OAuth service such as Github, Google+, Twitter,
>> ...
>> 
>> Whenever a user wants to login, keycloak shows a login screen (HTML Page)
>> with username+password fields as well as buttons for each of the services
>> that are configured. When clicking on "Github" for example, I am redirected
>> to a Github page asking me if I want to grant access to that application.
>> As soon ay I confirm this, I can simply login by clicking on the "Github"
>> button.
>> 
>> 
>> I am using a StageWebView for displaying the login screen and am using the
>> Adobe OAuth2 lib described here:
>> http://blogs.adobe.com/charles/2012/05/oauth-2-0-library-for-actionscript.html
>> 
>> OAuth 2.0 Library for ActionScript
>> Tweet
>> Weitere Informationen...<
>> http://blogs.adobe.com/charles/2012/05/oauth-2-0-library-for-actionscript.html
>>> 
>> 
>> 
>> 
>> Logging in with username+password works. Klicking on "github" however
>> doesn't. Investigating the communication with Wireshark now revealed that
>> when logging in with username+password a "http 302" response is returned
>> and that works fine. However if clicking on "github" keacloak returns a
>> "http 307" which should be handled slightly different. Unfortunately the
>> StageWebView doesn't react at all on this response.
>> 
>> 
>> Is this eventually not implemented? If yes ... is there a workaround or an
>> alternative to the StageWebView?
>> 
>> 
>> Chris
>> 
> 
> 
> 
> --
> WBR
> Maxim aka solomax


Re: StageWebView not able to understand Http 307 Responses?

Posted by Maxim Solodovnik <so...@gmail.com>.
sorry, never used Keycloak :(

On Fri, Sep 11, 2015 at 4:52 PM, Christofer Dutz <ch...@c-ware.de>
wrote:

> Hi Maxim,
>
> the problem is not authenticating against G+ from mobile, but
> authenticating against G+ using Keycloak. It's sort of a OAuth proxy you
> can use. It seems that this returns Http 307 responses for redirecting to
> the individual login pages.
>
> Chris
>
> ________________________________________
> Von: Maxim Solodovnik <so...@gmail.com>
> Gesendet: Freitag, 11. September 2015 11:24
> An: users@flex.apache.org
> Betreff: Re: StageWebView not able to understand Http 307 Responses?
>
> Hello Chris,
>
> I was able to auth against G+ using this code:
>
> http://stackoverflow.com/questions/10717919/how-to-integrate-google-in-a-flex-mobile-application
> (slightly modified)
>
> On Fri, Sep 11, 2015 at 3:10 PM, Christofer Dutz <
> christofer.dutz@c-ware.de>
> wrote:
>
> > Hi,
> >
> >
> > First of all ... this is probably more an AIR question as it is a Flex
> > question, but I am thinking that here eventually someone knows the answer
> > to this question.
> >
> >
> > I'm struggling to make my Flex-based mobile application use Keycloak as
> > OAuth2 server. So far I got most of it working.
> >
> >
> > For anyone not familiar with Keycloak. It allows me to: Create a login on
> > Keycloak itself or use an OAuth service such as Github, Google+, Twitter,
> > ...
> >
> > Whenever a user wants to login, keycloak shows a login screen (HTML Page)
> > with username+password fields as well as buttons for each of the services
> > that are configured. When clicking on "Github" for example, I am
> redirected
> > to a Github page asking me if I want to grant access to that application.
> > As soon ay I confirm this, I can simply login by clicking on the "Github"
> > button.
> >
> >
> > I am using a StageWebView for displaying the login screen and am using
> the
> > Adobe OAuth2 lib described here:
> >
> http://blogs.adobe.com/charles/2012/05/oauth-2-0-library-for-actionscript.html
> >
> > OAuth 2.0 Library for ActionScript
> > Tweet
> > Weitere Informationen...<
> >
> http://blogs.adobe.com/charles/2012/05/oauth-2-0-library-for-actionscript.html
> > >
> >
> >
> >
> > Logging in with username+password works. Klicking on "github" however
> > doesn't. Investigating the communication with Wireshark now revealed that
> > when logging in with username+password a "http 302" response is returned
> > and that works fine. However if clicking on "github" keacloak returns a
> > "http 307" which should be handled slightly different. Unfortunately the
> > StageWebView doesn't react at all on this response.
> >
> >
> > Is this eventually not implemented? If yes ... is there a workaround or
> an
> > alternative to the StageWebView?
> >
> >
> > Chris
> >
>
>
>
> --
> WBR
> Maxim aka solomax
>



-- 
WBR
Maxim aka solomax

AW: StageWebView not able to understand Http 307 Responses?

Posted by Christofer Dutz <ch...@c-ware.de>.
Hi Maxim, 

the problem is not authenticating against G+ from mobile, but authenticating against G+ using Keycloak. It's sort of a OAuth proxy you can use. It seems that this returns Http 307 responses for redirecting to the individual login pages. 

Chris

________________________________________
Von: Maxim Solodovnik <so...@gmail.com>
Gesendet: Freitag, 11. September 2015 11:24
An: users@flex.apache.org
Betreff: Re: StageWebView not able to understand Http 307 Responses?

Hello Chris,

I was able to auth against G+ using this code:
http://stackoverflow.com/questions/10717919/how-to-integrate-google-in-a-flex-mobile-application
(slightly modified)

On Fri, Sep 11, 2015 at 3:10 PM, Christofer Dutz <ch...@c-ware.de>
wrote:

> Hi,
>
>
> First of all ... this is probably more an AIR question as it is a Flex
> question, but I am thinking that here eventually someone knows the answer
> to this question.
>
>
> I'm struggling to make my Flex-based mobile application use Keycloak as
> OAuth2 server. So far I got most of it working.
>
>
> For anyone not familiar with Keycloak. It allows me to: Create a login on
> Keycloak itself or use an OAuth service such as Github, Google+, Twitter,
> ...
>
> Whenever a user wants to login, keycloak shows a login screen (HTML Page)
> with username+password fields as well as buttons for each of the services
> that are configured. When clicking on "Github" for example, I am redirected
> to a Github page asking me if I want to grant access to that application.
> As soon ay I confirm this, I can simply login by clicking on the "Github"
> button.
>
>
> I am using a StageWebView for displaying the login screen and am using the
> Adobe OAuth2 lib described here:
> http://blogs.adobe.com/charles/2012/05/oauth-2-0-library-for-actionscript.html
>
> OAuth 2.0 Library for ActionScript
> Tweet
> Weitere Informationen...<
> http://blogs.adobe.com/charles/2012/05/oauth-2-0-library-for-actionscript.html
> >
>
>
>
> Logging in with username+password works. Klicking on "github" however
> doesn't. Investigating the communication with Wireshark now revealed that
> when logging in with username+password a "http 302" response is returned
> and that works fine. However if clicking on "github" keacloak returns a
> "http 307" which should be handled slightly different. Unfortunately the
> StageWebView doesn't react at all on this response.
>
>
> Is this eventually not implemented? If yes ... is there a workaround or an
> alternative to the StageWebView?
>
>
> Chris
>



--
WBR
Maxim aka solomax

Re: StageWebView not able to understand Http 307 Responses?

Posted by Maxim Solodovnik <so...@gmail.com>.
Hello Chris,

I was able to auth against G+ using this code:
http://stackoverflow.com/questions/10717919/how-to-integrate-google-in-a-flex-mobile-application
(slightly modified)

On Fri, Sep 11, 2015 at 3:10 PM, Christofer Dutz <ch...@c-ware.de>
wrote:

> Hi,
>
>
> First of all ... this is probably more an AIR question as it is a Flex
> question, but I am thinking that here eventually someone knows the answer
> to this question.
>
>
> I'm struggling to make my Flex-based mobile application use Keycloak as
> OAuth2 server. So far I got most of it working.
>
>
> For anyone not familiar with Keycloak. It allows me to: Create a login on
> Keycloak itself or use an OAuth service such as Github, Google+, Twitter,
> ...
>
> Whenever a user wants to login, keycloak shows a login screen (HTML Page)
> with username+password fields as well as buttons for each of the services
> that are configured. When clicking on "Github" for example, I am redirected
> to a Github page asking me if I want to grant access to that application.
> As soon ay I confirm this, I can simply login by clicking on the "Github"
> button.
>
>
> I am using a StageWebView for displaying the login screen and am using the
> Adobe OAuth2 lib described here:
> http://blogs.adobe.com/charles/2012/05/oauth-2-0-library-for-actionscript.html
>
> OAuth 2.0 Library for ActionScript
> Tweet
> Weitere Informationen...<
> http://blogs.adobe.com/charles/2012/05/oauth-2-0-library-for-actionscript.html
> >
>
>
>
> Logging in with username+password works. Klicking on "github" however
> doesn't. Investigating the communication with Wireshark now revealed that
> when logging in with username+password a "http 302" response is returned
> and that works fine. However if clicking on "github" keacloak returns a
> "http 307" which should be handled slightly different. Unfortunately the
> StageWebView doesn't react at all on this response.
>
>
> Is this eventually not implemented? If yes ... is there a workaround or an
> alternative to the StageWebView?
>
>
> Chris
>



-- 
WBR
Maxim aka solomax