OAuth, Tumblr и Scope - PullRequest
       24

OAuth, Tumblr и Scope

3 голосов
/ 15 января 2012

Я пытаюсь войти в Tumblr через OAuth и приложение для Mac, которое начинаю кодировать.Я загрузил исходный код gtm-oauth, все в порядке.

Я только начал этот код внутри контроллера представления:

- (GTMOAuthAuthentication *)myCustomAuth {

    GTMOAuthAuthentication *auth;
    auth = [[[GTMOAuthAuthentication alloc] initWithSignatureMethod:kGTMOAuthSignatureMethodHMAC_SHA1
                                                        consumerKey:kConsumerKey
                                                         privateKey:kConsumerSecret] autorelease];
    auth.serviceProvider = @"Custom Auth Service";
    return auth;
}
- (void)viewController:(GTMOAuthViewControllerTouch *)viewController
      finishedWithAuth:(GTMOAuthAuthentication *)auth
                 error:(NSError *)error {
    NSLog(@"finishedWithAuth");
    if (error != nil) {
        NSLog(@"failed");
    } else {
        NSLog(@"done");
    }
}


- (void)signInToCustomService {

    GTMOAuthAuthentication *auth = [self myCustomAuth];
    if (auth == nil) {
        NSLog(@"A valid consumer key and consumer secret are required for signing in to Tumblr");
    }
    else
    {
        NSLog(@"Ok auth");
    }

    NSURL *requestURL = [NSURL URLWithString:@"http://www.tumblr.com/oauth/request_token"];
    NSURL *accessURL = [NSURL URLWithString:@"http://www.tumblr.com/oauth/access_token"];
    NSURL *authorizeURL = [NSURL URLWithString:@"http://www.tumblr.com/oauth/authorize"];

    NSString *scope = @"http://api.tumblr.com"; // HERE I DON'T KNOW WHAT TO WRITE

    GTMOAuthViewControllerTouch *viewController;
    viewController = [[[GTMOAuthViewControllerTouch alloc] initWithScope:scope
                                                                language:nil
                                                         requestTokenURL:requestURL
                                                       authorizeTokenURL:authorizeURL
                                                          accessTokenURL:accessURL
                                                          authentication:auth
                                                          appServiceName:@"My App: Custom Service"
                                                                delegate:self
                                                        finishedSelector:@selector(viewController:finishedWithAuth:error:)] autorelease];

    [self presentModalViewController:viewController animated:YES];
}


- (void)viewDidLoad
{
    [super viewDidLoad];
    [self signInToCustomService];
}

Но ничего не происходит.

- (void)viewController:(GTMOAuthViewControllerTouch *)viewController
      finishedWithAuth:(GTMOAuthAuthentication *)auth
                 error:(NSError *)error;

Этот метод никогда не вызывается.Возможно, это моя переменная области видимости.Я не знаю, какое значение я должен написать для этого.Спасибо за вашу помощь!

...