Skip to content
Browse files

Add error handling when return query string doesn't contain OAuth par…

…ameters

Signed-off-by: Mattt Thompson <m@mattt.me>
  • Loading branch information...
1 parent 3a8e7d6 commit 584b620f91b146c40268731dc75c35a0697fc3a5 @falkobuttler falkobuttler committed with mattt May 6, 2013
Showing with 15 additions and 4 deletions.
  1. +15 −4 AFOAuth1Client/AFOAuth1Client.m
View
19 AFOAuth1Client/AFOAuth1Client.m
@@ -264,10 +264,17 @@ - (void)authorizeUsingOAuthWithRequestTokenPath:(NSString *)requestTokenPath
currentRequestToken.verifier = [AFParametersFromQueryString([url query]) valueForKey:@"oauth_verifier"];
[self acquireOAuthAccessTokenWithPath:accessTokenPath requestToken:currentRequestToken accessMethod:accessMethod success:^(AFOAuth1Token * accessToken) {
- self.accessToken = accessToken;
-
- if (success) {
- success(accessToken);
+
+ if (accessToken) {
+ self.accessToken = accessToken;
+
+ if (success) {
+ success(accessToken);
+ }
+ } else {
+ if (failure) {
+ failure(nil);
+ }
}
} failure:^(NSError *error) {
if (failure) {
@@ -437,6 +444,10 @@ - (id)initWithQueryString:(NSString *)queryString {
}
NSDictionary *attributes = AFParametersFromQueryString(queryString);
+
+ if (attributes.count == 0) {
+ return nil;
+ }
NSDate *expiration = nil;
if (attributes[@"oauth_token_duration"]) {

0 comments on commit 584b620

Please sign in to comment.
Something went wrong with that request. Please try again.