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

发布于 2024-11-03 03:02:57 字数 1681 浏览 1 评论 0原文

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

桌面:

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 

I got pinless OAuth working on Adobe AIR for Desktop, iOS, but not Android.
For some reason, we're not getting the oauth_verifier (which contains the
sha'd code) in StageWebView on an Android device. Any clue? Here's the
debug for on desktop and on Droid 2; notice the 3rd line in the Droid 2 trace output which is missing
all the OAuth variables after the callback URL.

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 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

欢你一世 2024-11-10 03:02:57

我通过 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

另外,假设您的应用程序实际上注册为“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
    }
}

I fixed it via Event.COMPLETE for my Droid 2 and Nexus One. I'm not even getting a LocationChangeEvent.LOCATION_CHANGING on my desktop nor Android, but bottom line, Event.COMPLETE does get the oauth_verifier sha'd pin in it. I can parse that out of StageWebView's location property, submit, and I'm good to go. Out of paranoia, I'm leaving all 3 events in there just in case. If you're curious, here's the redirect event differences between OS's via Mark Lochrie: http://kb2.adobe.com/cps/895/cpsid_89526.html.

Also, it's assumed your application is actually registered as a "web application", and not a desktop application, otherwise, you'll be forced to use a pin, and you won't get the oauth_verifier in the response URL. Yes, you can make up a callback URL to whatever you want; just make sure it's a standard URL that hopefully doesn't 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
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文