I spent the last day (note: novice Objective-C programmer, but lots of experience in other languages) figuring out why gtm-oauth2 wouldn't connect to Basecamp API but now I've given up and asking here.

So I have an app that was written from scratch and it didn't work so I hacked the official OAuth2Sample provided with gtm-oauth2 and just changed the values of Dailymotion example with the correct values for Basecamp Auth and I got the same error.

I get the login page and then the authorization page and the error happens when I click "Yes, I'll allow access".

In the API console I get:

The operation couldn’t be completed. (com.google.GTMOAuth2 error -1000.)

and in the Xcode Output I get:

2012-12-05 09:35:45.569 OAuth2Sample[29512:303] *** Assertion failure in -[GTMOAuth2SignIn requestRedirectedToRequest:], /Path/To/Xcode/gtm-oauth2-read-only/Examples/OAuth2Sample/../../Source/GTMOAuth2SignIn.m:400
2012-12-05 09:35:45.570 OAuth2Sample[29512:303] *** WebKit discarded an uncaught exception in the webView:resource:willSendRequest:redirectResponse:fromDataSource: delegate: <NSInternalInconsistencyException> response lacks auth code or error

As mentioned, the code is the same as in the Google provided sample, I just changed the auth, token and redirect URL values.

UPDATE: Narrowed it down to this: On line 394 there is NSString *responseStr = [[redirectedRequest URL] query]; which should get the query but gets nil because URL is

2012-12-05 14:02:18.591 Basecamper[32630:303] req: http://madebybandit.com/#access_token=BAhbBy…long token here…2898

so I tried fragment instead of query so now it throws this:

2012-12-05 14:07:05.955 Basecamper[32630:303] -[__NSCFString unsignedLongValue]: unrecognized selector sent to instance 0x101a74f30
2012-12-05 14:07:05.956 Basecamper[32630:303] *** WebKit discarded an uncaught exception in the webView:resource:willSendRequest:redirectResponse:fromDataSource: delegate: <NSInvalidArgumentException> -[__NSCFString unsignedLongValue]: unrecognized selector sent to instance 0x101a74f30

Now what?

有帮助吗?

解决方案

"Fixed it" by using OAuth2Client which works flawlessly.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top