TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Dec 2014 |
Maintained by Unclaimed.
An OAuth 1.0a client using AFNetwork, ARC enabled.
It was tested against Twitter, Readability and Tumblr APIs.
Add the AFNetwork and both files, call - setConsumerKey:secret:
and - setAccessToken:secret
to set the signing parameters and all calls after that will be signed. If you want a non-authenticated call, use either - unsignedRequestWithMethod:path:parameters:
or - setSignRequests(NO)
.
Install AFNetwork and add the STLOAuthClient.m
and STLOAuthClient.h
.
consumerKey
and consumerSecret
(the values provided by the service), you can use - initWithBaseURL:consumerKey:secret:
(it is the designated initializer) or - setConsumerKey:secret:
;- getPath:parameters:success:failure:
, - postPath:parameters:success:failure:
, - putPath:parameters:success:failure:
, - deletePath:parameters:success:failure:
or - requestWithMethod:path:parameters:
;signRequests
, allowing you to control when a request is signed or not, but you can also use - unsignedRequestWithMethod:path:parameters:
/ - signedRequestWithMethod:path:parameters:
;realm
. If you don't set it, it assumes the value of baseURL
.Sure :
STLOAuthClient *client = [[STLOAuthClient alloc] initWithBaseURL:[NSURL URLWithString:@"https://www.readability.com/api/rest/v1/"]];
[client setConsumerKey:CONSUMER_KEY secret:CONSUMER_SECRET];
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
username, @"x_auth_username",
password, @"x_auth_password",
@"client_auth", @"x_auth_mode",
nil];
[client getPath:@"oauth/access_token/" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"SUccess %@", operation.responseString);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Failure, %@", error);
}];
Hey, I like it, don't change it.
BSD.
There are some functions / methods based on 3rd party code :
ASIHTTPRequest+OAuth.m
— Created by Scott James Remnant on 6/1/11.NSString+URLEncode.h
— Created by Scott James Remnant on 6/1/11.AFOAuth2Client.m
— Copyright (c) 2011 Mattt Thompson (http://mattt.me/).