Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle oauth_problem #145

Merged
merged 2 commits into from Jan 4, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions Classes/ShareKit/Core/Base Sharer Classes/SHKOAuthSharer.m
Expand Up @@ -162,6 +162,18 @@ - (void)tokenAuthorizeView:(SHKOAuthView *)authView didFinishWithSuccess:(BOOL)s
otherButtonTitles:nil] autorelease] show];
}

else if ([queryParams objectForKey:@"oauth_problem"])
{
SHKLog(@"oauth_problem reported: %@", [queryParams objectForKey:@"oauth_problem"]);

[[[[UIAlertView alloc] initWithTitle:SHKLocalizedString(@"Authorize Error")
message:error!=nil?[error localizedDescription]:SHKLocalizedString(@"There was an error while authorizing")
delegate:nil
cancelButtonTitle:SHKLocalizedString(@"Close")
otherButtonTitles:nil] autorelease] show];
success = NO;
}

else
{
self.authorizeResponseQueryVars = queryParams;
Expand Down
13 changes: 2 additions & 11 deletions Classes/ShareKit/Sharers/Services/LinkedIn/SHKLinkedIn.m
Expand Up @@ -151,19 +151,10 @@ - (void)tokenAccess:(BOOL)refresh
}


// If you need to add additional headers or parameters to the request_token request, uncomment this section:
/*
- (void)tokenRequestModifyRequest:(OAMutableURLRequest *)oRequest
{
// Here is an example that adds the user's callback to the request headers
[oRequest setOAuthParameterName:@"oauth_callback" withValue:authorizeCallbackURL.absoluteString];
}
*/


// If you need to add additional headers or parameters to the access_token request, uncomment this section:
- (void)tokenAccessModifyRequest:(OAMutableURLRequest *)oRequest
{
SHKLog(@"req: %@", authorizeResponseQueryVars);
// Here is an example that adds the oauth_verifier value received from the authorize call.
// authorizeResponseQueryVars is a dictionary that contains the variables sent to the callback url
[oRequest setOAuthParameterName:@"oauth_verifier" withValue:[authorizeResponseQueryVars objectForKey:@"oauth_verifier"]];
Expand Down Expand Up @@ -327,7 +318,7 @@ - (void)sendTicket:(OAServiceTicket *)ticket didFinishWithData:(NSData *)data

// Otherwise, all other errors should end with:
NSString *responseBody = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease];
NSLog(@"%@", responseBody);
SHKLog(@"%@", responseBody);
[self sendDidFailWithError:[SHK error:@"Why it failed"] shouldRelogin:NO];
}
}
Expand Down
10 changes: 5 additions & 5 deletions Classes/ShareKit/Sharers/Services/Twitter/SHKTwitter.m
Expand Up @@ -576,7 +576,7 @@ - (void)sendImage {
// to an appropriate size (max of img.ly) and then start trying to compress.

while ([imageData length] > 700000 && compression > 0.1) {
// NSLog(@"Image size too big, compression more: current data size: %d bytes",[imageData length]);
// SHKLog(@"Image size too big, compression more: current data size: %d bytes",[imageData length]);
compression -= 0.1;
imageData = UIImageJPEGRepresentation([item image], compression);

Expand Down Expand Up @@ -632,19 +632,19 @@ - (void)sendImage {

- (void)sendImageTicket:(OAServiceTicket *)ticket didFinishWithData:(NSData *)data {
// TODO better error handling here
// NSLog([[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease]);
// SHKLog([[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease]);

if (ticket.didSucceed) {
// Finished uploading Image, now need to posh the message and url in twitter
NSString *dataString = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease];
NSRange startingRange = [dataString rangeOfString:@"<url>" options:NSCaseInsensitiveSearch];
//NSLog(@"found start string at %d, len %d",startingRange.location,startingRange.length);
//SHKLog(@"found start string at %d, len %d",startingRange.location,startingRange.length);
NSRange endingRange = [dataString rangeOfString:@"</url>" options:NSCaseInsensitiveSearch];
//NSLog(@"found end string at %d, len %d",endingRange.location,endingRange.length);
//SHKLog(@"found end string at %d, len %d",endingRange.location,endingRange.length);

if (startingRange.location != NSNotFound && endingRange.location != NSNotFound) {
NSString *urlString = [dataString substringWithRange:NSMakeRange(startingRange.location + startingRange.length, endingRange.location - (startingRange.location + startingRange.length))];
//NSLog(@"extracted string: %@",urlString);
//SHKLog(@"extracted string: %@",urlString);
[item setCustomValue:[NSString stringWithFormat:@"%@ %@",[item customValueForKey:@"status"],urlString] forKey:@"status"];
[self sendStatus];
}
Expand Down
2 changes: 1 addition & 1 deletion Classes/ShareKit/Sharers/Services/Vkontakte/SHKVkontakte.m
Expand Up @@ -420,7 +420,7 @@ - (NSDictionary *) sendPOSTRequest:(NSString *)reqURl withImageData:(NSData *)im

NSString *errorMsg = [[dict objectForKey:@"error"] objectForKey:@"error_msg"];

NSLog(@"Server response: %@ \nError: %@", dict, errorMsg);
SHKLog(@"Server response: %@ \nError: %@", dict, errorMsg);

return dict;
}
Expand Down
Expand Up @@ -97,7 +97,7 @@ - (BOOL)webView:(UIWebView *)aWbView shouldStartLoadWithRequest:(NSURLRequest *)
[super dismissModalViewControllerAnimated:YES];
return NO;
}
NSLog(@"Request: %@", [URL absoluteString]);
SHKLog(@"Request: %@", [URL absoluteString]);
return YES;
}

Expand All @@ -114,7 +114,7 @@ -(void)webViewDidFinishLoad:(UIWebView *)webView {

NSArray *userAr = [[[[webView request] URL] absoluteString] componentsSeparatedByString:@"&user_id="];
NSString *user_id = [userAr lastObject];
NSLog(@"User id: %@", user_id);
SHKLog(@"User id: %@", user_id);
if(user_id){
[[NSUserDefaults standardUserDefaults] setObject:user_id forKey:kSHKVkonakteUserId];
}
Expand All @@ -126,19 +126,19 @@ -(void)webViewDidFinishLoad:(UIWebView *)webView {
[[NSUserDefaults standardUserDefaults] synchronize];
}

NSLog(@"vkWebView response: %@",[[[webView request] URL] absoluteString]);
SHKLog(@"vkWebView response: %@",[[[webView request] URL] absoluteString]);
[(SHKVkontakte *)delegate authComplete];
[self dismissModalViewControllerAnimated:YES];
} else if ([vkWebView.request.URL.absoluteString rangeOfString:@"error"].location != NSNotFound) {
NSLog(@"Error: %@", vkWebView.request.URL.absoluteString);
SHKLog(@"Error: %@", vkWebView.request.URL.absoluteString);
[self dismissModalViewControllerAnimated:YES];
}

}

-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {

NSLog(@"vkWebView Error: %@", [error localizedDescription]);
SHKLog(@"vkWebView Error: %@", [error localizedDescription]);
[self dismissModalViewControllerAnimated:YES];
}

Expand Down