Code Monkey home page Code Monkey logo

actionscript-oauth2's People

Contributors

charlesbihis avatar marcorei avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

actionscript-oauth2's Issues

Auth Code Grant with "urn:ietf:wg:oauth:2.0:oob" as redirect url

if your using "urn:ietf:wg:oauth:2.0:oob" as the redirect URL, the auth code is returned in the title of the response page.

So instead of parsing the redirect url in LocationChangeEvent.LOCATION_CHANGE. You need to parse the authorizationCodeGrant.stageWebView.title in Event.COMPLETE.

token retrieved but GetAccessTokenEvent empty

Project made with Apache flex 4.15 Air 20 for Desktop Windows 7
I did simple testing app using example code for retrieveing token and I have few issues.

  • if StageWebVew initialized with usenative false (new StageWebView(false)) doesn't work at all I see just web view loading error
  • if I initiate it with usenative = true it seens to be worked. but with errors. I recieved few GetAccessTokenEvent but both with null's inside. It's my log:

[trace] 2016/2/28 1:34:40.26 [INFO] com.adobe.protocols.oauth2.OAuth2 Initiating getAccessToken() with authorization code grant type workflow
[trace] 2016/2/28 1:34:40.30 [INFO] com.adobe.protocols.oauth2.OAuth2 Loading auth URL: https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=1005094869546-eso7913kn7uc0s39ha343c3e7460baek.apps.googleusercontent.com&redirect_uri=http://localhost&scope=email profile&state=
[trace] 2016/2/28 1:34:40.679 [INFO] com.adobe.protocols.oauth2.OAuth2 Loading URL: https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=1005094869546-eso7913kn7uc0s39ha343c3e7460baek.apps.googleusercontent.com&redirect_uri=http://localhost&scope=email profile&state=
[trace] 2016/2/28 1:34:41.114 [INFO] com.adobe.protocols.oauth2.OAuth2 Auth URL loading complete after 1085ms
[trace] 2016/2/28 1:34:42.544 [INFO] com.adobe.protocols.oauth2.OAuth2 Loading URL: https://accounts.google.com/o/oauth2/approval?as=-6f751a3b996912c&hl=en&pageId=none&xsrfsign=APsBz4gAAAAAVtI5l3Vnbcd7KGhiCt6EbQxBV6oei8WF
[trace] 2016/2/28 1:34:42.636 [INFO] com.adobe.protocols.oauth2.OAuth2 Loading URL: http://localhost/?code=4/T_Ej7lu-smhtAJrjQYiIVQmskdV1_FiFxaRQ0DcwXTE#
[trace] 2016/2/28 1:34:42.636 [INFO] com.adobe.protocols.oauth2.OAuth2 Redirect URI encountered (http://localhost). Extracting values from path.
[trace] 2016/2/28 1:34:42.636 [DEBUG] com.adobe.protocols.oauth2.OAuth2 Authorization code: 4/T_Ej7lu-smhtAJrjQYiIVQmskdV1_FiFxaRQ0DcwXTE#
[trace] 2016/2/28 1:34:42.639 [ERROR] com.adobe.protocols.oauth2.OAuth2 Error occurred with StageWebView: [ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="Load error: 0x800C0014." errorID=3228]
[trace] 2016/2/28 1:34:42.665 [INFO] com.adobe.protocols.oauth2.OAuth2 Loading URL: https://accounts.google.com/o/oauth2/approval?as=-6f751a3b996912c&hl=en&pageId=none&xsrfsign=APsBz4gAAAAAVtI5l3Vnbcd7KGhiCt6EbQxBV6oei8WF
[trace] 2016/2/28 1:34:42.695 [INFO] com.adobe.protocols.oauth2.OAuth2 Auth URL loading complete after 2666ms
[trace] 2016/2/28 1:34:42.952 [DEBUG] com.adobe.protocols.oauth2.OAuth2 Access token: ya29.lQJCxnMw56fPUHqkHWS2cgDQGXLQSRvQVUvRSVYSpwEKdx_nOK78qTomomIv8oGSQw
[trace] Your access token value is: null

Here is my testing code:

private function addAccount_mouseDownHandler(event:MouseEvent):void
        {
            var stageWebView:StageWebView = new StageWebView(true);
            stageWebView.stage = stage;
            stageWebView.viewPort = new Rectangle(0, 0, 500, 500);
            var oauth2:OAuth2 = new OAuth2("https://accounts.google.com/o/oauth2/auth",
                    "https://accounts.google.com/o/oauth2/token", LogSetupLevel.ALL);
            var grant:IGrantType = new AuthorizationCodeGrant(stageWebView,                     // the StageWebView object for which to display the user consent screen
                    "1005094869546-eso7913kn7uc0s39ha343c3e7460baek.apps.googleusercontent.com",          // your client ID
                    "tcAPaOZj16HcbG5eEQlLKwYX",      // your client secret
                    "http://localhost",       // your redirect URI
                    "email profile",              // (optional) your scope
                    "");             // (optional) your state

            oauth2.addEventListener(GetAccessTokenEvent.TYPE, onGetAccessToken);

            oauth2.getAccessToken(grant);

        }

        function onGetAccessToken(getAccessTokenEvent:GetAccessTokenEvent):void
        {
            if (getAccessTokenEvent.errorCode == null && getAccessTokenEvent.errorMessage == null)
            {
                // success!
                trace("Your access token value is: " + getAccessTokenEvent.accessToken);
            }
            else
            {
                // fail :(
            }
        } 

Looks like getAccessTokenEvent is owerwritten somwhere inside nested functions.
I did some rought fix here
com/adobe/protocols/oauth2/OAuth2.as:329


                    {
                        var response:Object = com.adobe.serialization.json.JSON.decode(event.target.data);
                        log.debug("Access token: " + response.access_token);
                        var getAccessTokenEvent2 = new GetAccessTokenEvent();
                        getAccessTokenEvent2.parseAccessTokenResponse(response);
                    }  // try statement
                    catch (error:JSONParseError)
                    {
                        getAccessTokenEvent2.errorCode = "com.adobe.serialization.json.JSONParseError";
                        getAccessTokenEvent2.errorMessage = "Error parsing output from access token response";
                    }  // catch statement

                    dispatchEvent(getAccessTokenEvent2);

so now it works for my situation,

Remove test directory from source path

The Project currently references a source path that is not available.
This is irritating because downloading and deploying the swc is not working "out of the box"

StageWebView Events

It would be nice if the OAuth2 class could fire off events to notify of StageWebView events. In particular a Load URI event and a Finished With StageWebView event. This is necessary because the StageWebView itself does not have a Load URI event. It only has a Change and Changing events. Knowing when a URI begins loading is necessary to implement a loading indicator. Also a Finished with StageWebView event would be nice to have so the app can close the StageWebView as soon as possible. This is particularly the case with installed apps, where the SageWebView will stay open awkwardly after completing the login, while the oauth token is retrieved in the second step.

Update state

Hi,
How can I update my state in twitter using this SDK?
Thanks

StageWebView Events

It would be nice if the OAuth2 class could fire off events to notify of StageWebView events. In particular a Load URI event and a Finished With StageWebView event. This is necessary because the StageWebView itself does not have a Load URI event. It only has a Change and Changing events. Knowing when a URI begins loading is necessary to implement a loading indicator. Also a Finished with StageWebView event (or a GetAuthCodeEvent) would be nice to have so the app can close the StageWebView as soon as possible. This is particularly the case with installed apps, where the SageWebView will stay open awkwardly after completing the login, while the oauth token is retrieved in the second step.

Thanks for taking a look at this issue. But I would like to clarify why these changes would be helpful. First off these are really only issues that would become serious when a user has a slow or unreliable internet connection. For this case I have been implementing a loading indicator, so the user knows there is no need to keep pressing submit. Also, at least in the case of the Google Installed App OAuth use case, the result page that shows once an auth code is obtained but before an access token, if it stays visible for more than a second it is misleading and confusing to the user because it instructs the user to copy and paste the code. This is why it would be nice to close the StageWebView as soon as possible.

As to the difference between locationChange, locationChanging and loadURL:
locationChange is fired when the page load is complete.
locationChanging is fired when page starts loading but is not fired when loadURL initiates that change. From the docs: "A locationChanging event is only dispatched when the location change is initiated through HTML content or code running inside the StageWebView object,such as when a user clicks a link. "

To implement a loading indicator, I have found that I need to know when loadURL is called, because no event is raised otherwise.

With regard to listening for a GetAccessTokenEvent:
The GetAccessTokenEvent is not fired when the auth code is obtained. But rather there is a delay between when the auth code is obtained and the access token is granted while a call to the tokenEndpoint is made. Usually this is fast and unnoticeable, but in the case of slow or unreliable internet it can cause the auth code result page to linger, leading to confusion. It would be nice to know when the auth code process is complete so the WebStageView can be closed.

Admittedly these are not urgent issues, but these improvements will enable an enhanced user experience.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.