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);
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.
Here is my testing code:
Looks like getAccessTokenEvent is owerwritten somwhere inside nested functions.
I did some rought fix here
com/adobe/protocols/oauth2/OAuth2.as:329
so now it works for my situation,