一个简单的 Uber OAuth 登录封装

692 阅读1分钟
原文链接: github.com

Pod Version Pod Platform Pod License

UberOAuth2 is a simple Objective-C wrapper for Uber OAuth2 login.

the Uber API url is Uber API .

UberOAuth2 is used for uber.com.cn,but also can be used for uber.com .and you need register uber developer , you need set clientid and clientsecret,redirecturl,and so on.

Podfile

platform :ios, '7.0'
pod 'UberOAuth2', '~> 0.1.1'

Instruction

OAuth2 login

UberLoginWebViewController *webViewController=[[UberLoginWebViewController alloc] init];
    NSString *urlString=[NSString stringWithFormat:@"https://login.uber.com.cn/oauth/v2/authorize?client_id=%@&redirect_url=%@&response_type=code&scope=profile history places history_lite",ClientId,RedirectUrl ];
    NSString *encodedUrlString = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    webViewController.urlString=encodedUrlString;
    webViewController.resultCallBack=^(NSDictionary *jsonDict, NSURLResponse *response, NSError *error){
        NSLog(@"access token %@ ",jsonDict);
    };
    [self presentViewController:webViewController animated:YES completion:nil];

get user profile through accesstoken

    [UberAPI requestUserProfileWithResult:^(NSDictionary *jsonDict, NSURLResponse *response, NSError *error){
        NSLog(@"user profile %@ ",jsonDict);
    }];

Uber OAuth2 Flow

Licenses

All source code is licensed under the MIT License.