安卓Adobe AIR上的无PIN OAuth

3

我已经在Adobe AIR桌面版和iOS上实现了无Pin OAuth,但在Android上没有。出于某种原因,在Android设备的StageWebView中我们没有获得oauth_verifier(其中包含sha'd代码)。有任何线索吗?以下是桌面和Droid 2的调试信息;请注意Droid 2跟踪输出中缺少回调URL后的所有OAuth变量的第3行。

桌面:

AuthorizeTwitterService::onComplete, data: 
oauth_token=De2k4zANjzAhT3hXV4eqOfTVxJsshVIJjgsuwPMUg8&oauth_token_secret=s     WsBzyS43nh6DDBwLaogaWpVftoDaiYTJDfBKQE&oauth_callback_confirmed=true 
-------------------- 
TwitterLoginView::onLocationChange 
location: 
https://api.twitter.com/oauth/authorize?oauth_callback=oob&applicatio... 
-------------------- 
TwitterLoginView::onLocationChange 
location: https://api.twitter.com/oauth/authorize 
-------------------- 
TwitterLoginView::onLocationChange 
location: 
http://www.twitter.com/combovercharlie?oauth_token=De2k4zANjzAhT3hXV4&oauth_verifier=js1B4bAYfUer05a2rlZSDcOLOaIa66q93K24FUzrk

Droid 2:

AuthorizeTwitterService::onComplete, data: 
oauth_token=BtwJHbpaS5OWy1AMYdwl0ecGKGpU9AEcyrFYaXQ8&oauth_token_secret=Z2C     ff3ECfY5dp8dLLSA9qXvL2SRaZ3v5veStGuA00&oauth_callback_confirmed=true 
-------------------- 
TwitterLoginView::onLocationChange 
location: 
https://api.twitter.com/oauth/authorize?oauth_callback=oob&applicatio... 
Charlie&oauth_token=BtwJHbpaS5OWy1AMYdwl0ecGKGpU9AEcyrFYaXQ8&oauth_consumer     _key=LbMYslVau91uSAMZyGsOg 
-------------------- 
TwitterLoginView::onLocationChange 
location: https://api.twitter.com/oauth/authorize 
-------------------- 
TwitterLoginView::onLocationChange 
location: http://mobile.twitter.com/combovercharlie 
1个回答

0

我通过Event.COMPLETE修复了我的Droid 2和Nexus One。在我的桌面或Android上,我甚至没有收到LocationChangeEvent.LOCATION_CHANGING事件,但是最重要的是,Event.COMPLETE确实包含了oauth_verifier sha'd pin。我可以从StageWebView的location属性中解析出来,提交并且一切正常。出于谨慎起见,我仍然保留了所有3个事件。如果你好奇,这里是Mark Lochrie通过http://kb2.adobe.com/cps/895/cpsid_89526.html展示的操作系统之间的重定向事件差异。

此外,假设您的应用程序实际上已注册为“Web应用程序”,而不是桌面应用程序,否则,您将被迫使用pin,并且您将无法在响应URL中获得oauth_verifier。是的,您可以编写任何您想要的回调URL;只需确保它是一个标准的URL,希望它不会404。

stageWebView = new StageWebView();
stageWebView.addEventListener(LocationChangeEvent.LOCATION_CHANGING, onLocationChange);
stageWebView.addEventListener(LocationChangeEvent.LOCATION_CHANGE, onLocationChange);
stageWebView.addEventListener(Event.COMPLETE, onLocationChange);
stageWebView.stage = stage;
stageWebView.viewRect = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);
// loaded from an OAuth library
// try http://code.google.com/p/oauth-as3/ or Tweetr http://wiki.swfjunkie.com/tweetr
stageWebView.loadURL(authenticationURL); 

var code:String;

function onLocationChange(event:Event):void
{
        var location:String;

    if(event is LocationChangeEvent)
    {
        location = LocationChangeEvent(event).location;
    }
    else
    {
        location = _stageWebView.location;
    }

    var search:String       = "oauth_verifier=";
    var ver:String          = location;
    var startIndex:int      = ver.lastIndexOf(search);
    if(startIndex != -1)
    {
        code = ver.substr(startIndex + search.length, location.length);
        // remove listeners and dispatch success here
    }
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接