使用Instagram API进行身份验证时,gtm-oauth2在Mac OSX上崩溃

时间:2014-03-18 01:41:43

标签: objective-c macos oauth-2.0 instagram gtm-oauth2

我正在Mac OSX上构建一个供个人使用的小型Instagram客户端。我目前正在使用gtm-oauth2从Instagram获取oauth2令牌。我按照源提供的指南来获取此令牌。我有90%的工作时间。 webView加载了身份验证详细信息,我可以输入我的帐户,然后会出现权限屏幕,询问我是否要授予我的应用程序访问权限。我遇到的问题是,在进行身份验证后,无论我是否允许"或"取消",应用程序崩溃,没有堆栈跟踪或其他信息。我得到的关于异常的唯一信息是"线程1:EXC_BAD_ACCESS(代码= 1,地址= 0x4c1)"似乎该线程正在与WebCore :: ResourceLoader做一些事情,但它是一堆ASM,所以我不知道这个调用实际发生在哪里。也许我没有正确调用windowController?我的代码包含在下面。

- (void)signIntoInstagram {

NSURL *tokenURL =[NSURL URLWithString:kTOKENIURl];

// Set up the OAuth request

GTMOAuth2Authentication *auth = [GTMOAuth2Authentication
                                 authenticationWithServiceProvider:@"Instagram"
                                 tokenURL:tokenURL
                                 redirectURI:kREDIRECTURI
                                 clientID:KCLIENTID
                                 clientSecret:KCLIENTSERCRET
                                 ];

// Specify the appropriate scope string, if any, according to the service's API documentation
auth.scope = @"basic";

NSURL *authURL = [NSURL URLWithString:KAUTHURL];

// Display the authentication view
GTMOAuth2WindowController *windowController;
windowController = [GTMOAuth2WindowController controllerWithAuthentication:auth
                                                          authorizationURL:authURL
                                                          keychainItemName:kKeychainItemName
                                                            resourceBundle:nil];

// optional: display some html briefly before the sign-in page loads
NSString *html = @"<html><body><div align=center>Loading sign-in page...</div></body></html>";
[windowController setInitialHTMLString:html];

[windowController signInSheetModalForWindow:_window
                                   delegate:self
                           finishedSelector:@selector(windowController:finishedWithAuth:error:)];}

如果我在windowController:finishedWithAuth:error:方法中插入断点,则应用程序将到达它。但是,在我运行之后它仍然崩溃,这对我来说似乎是某种异步操作导致错误。希望我在这里错过一些简单的东西;我无法想象Google的OAuth项目存在重大缺陷。

1 个答案:

答案 0 :(得分:3)

我遇到同样的问题https://groups.google.com/forum/#!msg/gtm-oauth/N6jlOpL9k5g/n4TdrTJyxzcJ后,我在Google群组中发现了这个问题。还记录了一个问题https://code.google.com/p/gtm-oauth/issues/detail?id=11

基本上我注释掉了GTMOAuth2WindowController.m的第331行并且它有效。您也可以添加对该问题的投票,也许Google会修复它。