OAuth2 0.2.3

OAuth2 0.2.3

测试已测试
语言 Obj-CObjective C
许可证 MIT
发布最后发布2017年5月

Trong Dinh 维护。



OAuth2 0.2.3

  • 作者:
  • Trong Dinh

OAuth2-for-iOS

这是一个适合 OAuth2 的 iOS 库。它支持授权使用 OAuth2 的所有网站,例如:smartthings、uber、fitbit、快递等...

概述

  1. https://github.com/lukeredpath/LROAuth2Client:我是基于这个库进行开发的。基本上,它覆盖了 > 80% 的工作。请分享并感谢他。

  2. https://github.com/nicklockwood/Base64:这是我用于此库的 base64 库。

改进

  1. UI

    • 使用自动布局。
    • 使用 ARC。
    • 改善用户体验。
  2. 授权

    • 为 OAuthRequestController 添加了 initWithDict 函数。
    • 添加了授权密钥,以避免一些网站需要它。
  3. 更多内容

    • 修正了 LROAuth2Client 的警告和一些小问题。
    • 升级库到 pod 项目,便于使用。

用法

  1. 要运行示例项目,请克隆仓库,然后首先从 Example 目录运行 pod install

  2. 声明 OAuthRequestController

NSMutableDictionary *dictService = [NSMutableDictionary dictionary];
[dictService setObject:@"https://www.fitbit.com/oauth2/authorize" forKey:kOAuth_AuthorizeURL];
[dictService setObject:@"https://api.fitbit.com/oauth2/token" forKey:kOAuth_TokenURL];
[dictService setObject:@"YOUR CLIENT ID" forKey:kOAuth_ClientId];
[dictService setObject:@"YOUR SECRET KEY" forKey:kOAuth_Secret];
[dictService setObject:@"YOUR CALLBACK URL" forKey:kOAuth_Callback];
[dictService setObject:@"activity heartrate location nutrition profile settings sleep social weight" forKey:kOAuth_Scope];


OAuthRequestController *oauthController = [[OAuthRequestController alloc] initWithDict:dictService];
oauthController.view.frame = self.view.frame;
oauthController.delegate = self;
[self presentViewController:oauthController animated:YES completion:^{

}];
  1. 实现 OAuthRequestController 方法以获取 accesstoken
- (void)didAuthorized:(NSDictionary *)dictResponse {
    NSLog(@"%@", dictResponse);
}

安装

OAuth2 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中:

pod "OAuth2"

作者

Trong Dinh,

许可证

OAuth2 根据 MIT 许可证提供。有关更多信息,请参阅 LICENSE 文件。