0

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?

Miha Rekar
  • 1,237
  • 12
  • 15
  • There is not enough information in your post to know what is being sent to the server, or what responses are being received. The gtm-oauth2 code tries to get an access code from the redirect URL, not an access token, so something about Basecamp's protocol or your use of it is too different from what the library is expecting. – grobbins Dec 05 '12 at 16:58
  • @grobbins as I've explained in the UPDATE I already found out that the Basecamp API does everything right except for using # instead of ? in URL. But now there is something amiss with `unsigned long deltaSeconds = [expiresIn unsignedLongValue];` . When I breakpoint it there and try `po expiresIn` I get `(NSNumber *) $51 = 0x0000000101d665d0 1209600` but when I try `po [expiresIn unsignedLongValue]` it returns `(id) $52 = 0x0000000000000000 ` so the app crashes. – Miha Rekar Dec 05 '12 at 17:27

1 Answers1

0

"Fixed it" by using OAuth2Client which works flawlessly.

Miha Rekar
  • 1,237
  • 12
  • 15