Question

My code looks something like this :

OAConsumer *consumer = [[OAConsumer alloc] initWithKey:@"my_ClientID"
                                                secret:@"my_Secret"];

NSURL *url = [NSURL URLWithString:@"https://launchpad.37signals.com/authorization/token"];

OAMutableURLRequest *request = [[OAMutableURLRequest alloc] initWithURL:url
                                                               consumer:consumer
                                                                  token:nil   // we don't have a Token yet
                                                                  realm:nil   // our service provider doesn't specify a realm
                                                      signatureProvider:nil]; // use the default method, HMAC-SHA1

[request setHTTPMethod:@"POST"];

NSLog(@"USER URL : %@",[request URL]);
OADataFetcher *fetcher = [[OADataFetcher alloc] init]; 

[fetcher fetchDataWithRequest:request
                     delegate:self
            didFinishSelector:@selector(requestTokenTicket:didFinishWithData:)
              didFailSelector:@selector(requestTokenTicket:didFailWithError:)];

.

- (void)requestTokenTicket:(OAServiceTicket *)ticket didFinishWithData:(NSData *)data {
    if (ticket.didSucceed) {
        NSString *responseBody = [[NSString alloc] initWithData:data
                                                       encoding:NSUTF8StringEncoding];
        OAToken *requestToken = [[OAToken alloc] initWithHTTPResponseBody:responseBody];
        NSLog(@"%@",requestToken);
    }
}

My Delegate method never gets a (ticket.didSucceed) Success.

Can someone tell me what I am missing here?

Thanks

Était-ce utile?

La solution

It looks like you are trying to have the user authorize your app and generate the token for the first time. For this, you're using the wrong URL. From the 37Signals API:

  1. Your app requests authorization by redirecting your user to Launchpad: https://launchpad.37signals.com/authorization/new?type=web_server&client_id=your-client-id&redirect_uri=your-redirect-uri

The URL you are using is for getting the access token from the verification code.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top