在iPad上通过Box进行身份验证 [英] Authentication with Box on iPad

查看:295
本文介绍了在iPad上通过Box进行身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为iPad应用添加Box支持。我尝试了官方SDK,但由于以下原因,我不想使用它:

I'm adding Box support to an iPad app. I tried the official SDK and I don't want to use it for the following reasons:


  1. 登录页面太宽在iPad上具有 UIModalPresentationFormSheet 样式的模式控制器。 SDK托管 UIWebView ,该加载项加载 https ://m.box.net/api/1.0/auth/ ,它可能会返回最小宽度设置为768px的HTML(尽管我没有检查HTML,在这里推测)。

  1. Login page is too wide for a modal controller with UIModalPresentationFormSheet style on iPad. The SDK hosts UIWebView which loads content of https://m.box.net/api/1.0/auth/, which perhaps returns HTML with min width set to 768px (although I didn't check the HTML, speculating here).

登录页面中的HTML不显示Google Apps身份验证选项。该页面的完整桌面版本可以。

HTML in login page doesn't show Google Apps authentication option. The full desktop version of the page does.

因为登录页面托管在用户的 UIWebView 中不能确定他是向Box而不是应用程序作者提供凭据。

Because the login page is hosted in UIWebView the user cannot be sure that he's supplying the credentials to Box, and not to an app author.

我不需要整个SDK功能,仅需要身份验证,文件夹/文件列表和内容下载。由于我的应用程序还使用其他云存储提供商,因此我希望提供统一的文件浏览体验。

I don't need the whole SDK functionality, just authentication, folder/file listing and content download. Since my app also uses other cloud storage providers I'd prefer to provide uniform file browsing experience.

'要做:


  1. 为我的应用添加自定义网址方案,例如 myapp。

  1. Add a custom URL scheme for my app, let's say "myapp".

在我应用程序的Box的应用程序设置中,将重定向URL设置为 myapp:// RedirFromBoxAuth

In Box's Application settings for my app set Redirect URL to myapp://RedirFromBoxAuth.

当用户选择从我的应用程序内部浏览Box时,我将转到:

When the user chooses to browse Box from inside my app, I'm going to:


  1. 通过调用 GET获得票证https://www.box.com/api/1.0/rest?action=get_ticket&_api_key={API_KEY }

提取票证,然后用<$ c调用 openUrl $ c> https://www.box.com/api/1.0/auth/ {TICKET} 这将打开Safari并让用户输入其凭据。这是登录页面的完整桌面版本。

Extract the ticket, then call openUrl with https://www.box.com/api/1.0/auth/{TICKET} This will open Safari and let the user enter his credentials. This is the full, desktop version of the login page.

成功登录后,Box的服务器将通知Safari重定向到 myapp:/ / RedirFromBoxAuth?ticket = {TICKET}& auth_token = {TOKEN} ,这将告诉iOS将控制权交给我的应用。

On successful login Box's server will tell Safari to redirect to myapp://RedirFromBoxAuth?ticket={TICKET}&auth_token={TOKEN}, which in turn will tell iOS to yield control to my app.

我的应用程序收到 handleOpenURL 通知,从现在开始,我可以提取身份验证令牌并使用REST API。

My app receives handleOpenURL notification and I can extract the authentication token and use REST API from now on.

请发表评论,这是一个好计划吗?我创建了一个快速的原型,它似乎可以运行,但是也许我缺少一些东西?

Please comment, is it a good plan? I created a quick prototype and it seems to work, but maybe I'm missing something?

Box团队,请告诉我们使用该身份验证模型的应用是否会可以包含在OneCloud中吗?

Box team, could you please tell us will an app using this authentication model be eligible for inclusion in OneCloud?

推荐答案

这似乎是个不错的策略,并且可能会比正常重定向。通过这种方式实现它,如果遇到任何奇怪的情况,请告诉我们。

This seems like a good strategy and will probably make for a better UX/easier implementation than the normal redirect. Please let us know if you run into any weird edge cases by implementing it this way.

这篇关于在iPad上通过Box进行身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆