gpt4 book ai didi

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

转载 作者:搜寻专家 更新时间:2023-10-30 20:09:10 25 4
gpt4 key购买 nike

我正在 Mac OSX 上构建一个供个人使用的小型 Instagram 客户端。我目前正在使用 gtm-oauth2 从 Instagram 获取 oauth2 token 。我正在按照源代码提供的指南获取此 token 。我已经完成了 90% 的工作。 webView 加载了身份验证详细信息,我可以输入我的帐户,然后出现权限屏幕询问我是否愿意授予我的应用程序访问权限。我遇到的问题是,在进行身份验证后,无论我是“允许”还是“取消”,应用程序都会崩溃,没有堆栈跟踪或其他信息。我得到的关于异常的唯一信息是“Thread 1: EXC_BAD_ACCESS (code = 1, address=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 项目存在重大缺陷。

最佳答案

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

基本上我注释掉了 GTMOAuth2WindowController.m 的第 331 行并且它起作用了。您还可以对该问题投上您的一票,也许 Google 会解决它。

关于objective-c - 使用 Instagram API 进行身份验证时,gtm-oauth2 在 Mac OSX 上崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22468877/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com