AVISO: Cualquier pregunta que no cumpla ninguno de estos criterios podrá ser borrada sin previo aviso.

GTMOAuth + Tripit

Saludos,

Estoy añadiendo soporte del servicio web Tripit a mi aplicacion. Estoy usando la librería GTMOAuth de google (GTMOAuth) para acceder mediante OAuth. Me encanta esta librería porque permite la autorización directamente en la app sin saltar a Safari.

El código para acceder es el siguiente:

NSString *myConsumerKey = kTripItAPIKey;        // pre-registered with service
NSString *myConsumerSecret = kTripItAPISecret;  // pre-assigned by service

GTMOAuthAuthentication *auth = [[[GTMOAuthAuthentication alloc] initWithSignatureMethod:kGTMOAuthSignatureMethodHMAC_SHA1
                                                                        consumerKey:myConsumerKey
                                                                         privateKey:myConsumerSecret] autorelease];

// setting the service name lets us inspect the auth object later to know
// what service it is for
auth.serviceProvider = @"Tripit";

NSURL *requestURL = [NSURL URLWithString:@"https://api.tripit.com/oauth/request_token"];
NSURL *accessURL = [NSURL URLWithString:@"https://api.tripit.com/oauth/access_token"];
NSURL *authorizeURL = [NSURL URLWithString:@"https://m.tripit.com/oauth/authorize"];
NSString *scope = @"https://api.tripit.com/scope";

GTMOAuthAuthentication *auth = [self myCustomAuth];

// set the callback URL to which the site should redirect, and for which
// the OAuth controller should look to determine when sign-in has
// finished or been canceled
//
// This URL does not need to be for an actual web page
[auth setCallback:@"https://api.tripit.com/OAuthCallback"];

// Display the autentication view
GTMOAuthViewControllerTouch *viewController = [[[GTMOAuthViewControllerTouch alloc] initWithScope:scope
                                                                                     language:nil
                                                                              requestTokenURL:requestURL
                                                                            authorizeTokenURL:authorizeURL
                                                                               accessTokenURL:accessURL
                                                                               authentication:auth
                                                                               appServiceName:@"AppName"
                                                                                     delegate:self
                                                                             finishedSelector:@selector(viewController:finishedWithAuth:error:)] autorelease];

[[self navigationController] pushViewController:viewController
                                   animated:YES];

Cuando accedo con el webview que me da el viewController obtengo un mensaje de acceso denegado. La documentación oficial de Tripit es bastante mediocre en lo que a iOS se refiere (Documentacion Tripit) y no habla nada del scope ni del callback. Alguien con más conocimientos en webservices puede ayudarme, gracias.

preguntado 14 Feb '12, 14:53

Soulless's gravatar image

Soulless
59161421


Me respondo a mi mismo, pero por si le sirve a alguien en el futuro. El scope puede ponerse a nil y el callback ha de coincidir con la URL que se especifica sobre la aplicación. En el profile de la aplicación, Tripit pregunta: "URL where a user can learn about your application (optional)". Esa URL debe coincidir con la colocada en el método setCallback.

Espero que le sea útil a alguien en el futuro. Y horrible documentacion de Tripit para iOS. :-/

enlace permanente

respondido 14 Feb '12, 23:04

Soulless's gravatar image

Soulless
59161421

Tu respuesta:
Activar/desactivar vista previa