适用于 Android 的 Adob​​e AIR 上的无引脚 OAuth

2024-02-06

我在 Adob​​e AIR for Desktop、iOS 上使用了无引脚 OAuth,但在 Android 上则不行。 由于某种原因,我们没有得到 oauth_verifier (其中包含 Android 设备上 StageWebView 中的 sha'd 代码)。有什么线索吗?这是 在桌面和 Droid 2 上进行调试;请注意 Droid 2 跟踪输出中缺少的第三行 回调 URL 后面的所有 OAuth 变量。

Desktop:

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 

我通过 Event.COMPLETE 为我的 Droid 2 和 Nexus One 修复了这个问题。我什至没有在我的桌面上或 Android 上获得 LocationChangeEvent.LOCATION_CHANGING,但最重要的是,Event.COMPLETE 确实获得了 oauth_verifier sha'd pin。我可以从 StageWebView 的位置属性中解析它,然后提交,然后就可以开始了。出于偏执,我将所有 3 个事件都留在那里以防万一。如果您好奇,以下是 Mark Lochrie 提供的操作系统之间的重定向事件差异:http://kb2.adobe.com/cps/895/cpsid_89526.html 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
    }
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

适用于 Android 的 Adob​​e AIR 上的无引脚 OAuth 的相关文章

随机推荐