OAuth1 0.3

OAuth1 0.3

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release May 2017

Maintained by Trong Dinh.



OAuth1 0.3

OAuth1-for-iOS

It's a library on iOS which is suitable for OAuth1.

OVERVIEW

The idea based on FHSTwitterEngine (https://github.com/natesymer/FHSTwitterEngine) but has reduced more code and make it lightweight and suitable for all others OAuth1.

Usage

  1. To run the example project, clone the repo, and run pod install from the Example directory first.

  2. Declare FHSTwitterEngine:

[[FHSTwitterEngine sharedEngine] setDelegate:self];
    if([[FHSTwitterEngine sharedEngine] isAuthorized]) {
        NSLog(@"YES");
        [self callUserRequest];
        
    } else {
        NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:@"https://api.twitter.com/oauth/access_token", kOAuth1_TOKEN,
                                                                        @"https://api.twitter.com/oauth/request_token", kOAuth1_REQUEST_TOKEN,
                                                                        @"https://api.twitter.com/oauth/authorize", kOAuth1_AUTHORIZE,
                                                                        @"yRtOrW7lOURB0lTSaTWlN2fMv", kOAuth1_CONSUMER_KEY,
                                                                        @"xOjRhL9mqzFf7Ie6Zv647K8FjPVeQyt2LcyPGAbkPYYae05VwP", kOAuth1_SECRET_KEY, nil];
        
        NSError *err = [[FHSTwitterEngine sharedEngine] authWithInfo:dict];
        if (!err) {
            UIViewController *loginController = [[FHSTwitterEngine sharedEngine]loginControllerWithCompletionHandler:^(BOOL success) {
                if(success) {
                    NSLog(@"YES");
                    [self callUserRequest];
                } else {
                    NSLog(@"NO");
                }
            }];
            [self presentViewController:loginController animated:YES completion:^{
                
            }];
        }

    }
  1. Implement FHSTwitterEngineAccessTokenDelegate method to obtain accesstoken:
- (void)oauth1Reponsed:(NSDictionary *)dict {
    NSLog(@"%@", dict);
}
  1. Call custom request:
- (void)callUserRequest {
    id data = [[FHSTwitterEngine sharedEngine] sendGETRequestForURL:[NSURL URLWithString:@"https://api.twitter.com/1.1/account/verify_credentials.json"] andParams:nil];
    NSLog(@"%@", data);
}

Installation

  1. Pod:
  • OAuth1 is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "OAuth1"
  1. Carthage:
  • For Carthage installation:
github "trongdth/OAuth1-for-iOS" "master"

Author

Trong Dinh, [email protected]

License

OAuth1 is available under the APACHE license. See the LICENSE file for more info.