BoxSimpleOAuth 0.2.1

BoxSimpleOAuth 0.2.1

测试已测试
Lang语言 Obj-CObjective C
许可证 MIT
Released上次发布2019年7月

rbaumbachRyan Baumbach 维护。



 
依赖
SimpleOAuth2= 0.1.5
MBProgressHUD>= 0.9
 

  • 作者:
  • Ryan Baumbach

BoxSimpleOAuth Bitrise Cocoapod Version Carthage Compatible Cocoapod Platform License

一种快速简单的方法,用于在您的 iPhone 或 iPad 应用程序中验证 Box 用户。

iPhone 7 Screenshot iPad Pro 9.7 Screenshot

将 BoxSimpleOAuth 添加到您的项目

CocoaPods

CocoaPods 是将 BoxSimpleOAuth 添加到项目的推荐方式。

  1. 将 BoxSimpleOAuth 添加到 Podfile:pod 'BoxSimpleOAuth'.
  2. 运行 pod install 安装 pod。
  3. 使用 #import <BoxSimpleOAuth/BoxSimpleOAuth.h> 将 BoxSimpleOAuth 添加到您的文件中。

Carthage

  1. github "rbaumbach/BoxSimpleOAuth" 添加到 Cartfile。
  2. 按照说明添加动态框架到您的目标。

从 Github 克隆

  1. 从 github 克隆存储库并直接复制文件,或将其作为 git 子模块添加。
  2. 将 'Source' 目录下的所有文件添加到您的项目。

操作方法

  • 创建一个 BoxSimpleOAuthViewController 实例,并传入一个 Box 客户端 ID、客户端密钥、客户端回调 URL 和一个完成块,用于执行带有 BoxLoginResponseNSError 参数的操作。
  • 一旦 BoxSimpleOAuthViewController 实例被展示(无论是以模态或被推送到导航堆栈),它将允许用户登录。用户登录后,初始时在视图控制器中给出的完成块将被执行。完成块中的参数,BoxLoginResponse,包含一个 accessToken 和其他由 Box API 响应 提供的登录信息。如果在尝试认证时出现问题,则将给出错误。
  • 默认情况下,如果认证存在问题,将会显示一个 UIAlertView。要禁用此功能,并直接依赖 NSError,将属性 shouldShowErrorAlert 设置为 NO。
  • 可以使用底层的 BoxAuthenticationManager 刷新 access_token。
  • 注意:尽管视图控制器的实例可以在没有客户端ID、客户端密钥、客户端回调和完成块的情况下进行初始化(以帮助测试),但在向用户展示之前,必须使用视图控制器的属性设置这些数据。

示例用法

// Simplest Example:

BoxSimpleOAuthViewController
    *viewController = [[BoxSimpleOAuthViewController alloc] initWithClientID:@"panchos_client_id"
                                                                clientSecret:@"shhhhhh, I'm a secret"
                                                                 callbackURL:[NSURL URLWithString:@"http://chihuahuas.dog"]
                                                                  completion:^(BoxLoginResponse *response, NSError *error) {
                                                                      NSLog(@"My Access Token is: %@", response.accessToken);
                                                                  }];
[self.navigationController pushViewController:viewController
                                     animated:YES];

// Disable error UIAlertViews Example:

BoxSimpleOAuthViewController
    *viewController = [[BoxSimpleOAuthViewController alloc] initWithClientID:@"pancho_jrs_client_id"
                                                                clientSecret:@"shhhhhh, I'm a secret"
                                                                 callbackURL:[NSURL URLWithString:@"http://your.fancy.site"]
                                                                  completion:^(BoxLoginResponse *response, NSError *error) {
                                                                      NSLog(@"My OAuth Token is: %@", response.accessToken);
                                                                  }];
viewController.shouldShowErrorAlert = NO;

[self.navigationController pushViewController:viewController
                                     animated:YES];

测试

此项目已配置用于使用fastlane运行测试。

首先,在项目目录中运行setup.sh脚本来安装所需的gem和CocoaPods

$ ./setup.sh

然后,使用fastlane在命令行上运行所有的spec

$ bundle exec fastlane specs

版本历史

版本历史可以在发布页面找到。

建议、请求和反馈

感谢您考虑使用BoxSimpleOAuth进行应用内Box身份验证。任何反馈可以通过:[email protected]发送。