I’m trying to prototype an app which utilizes Soundcloud’s API endpoints, and integrates the cocoa-api-wrapper for cocoa and cocoa touch projects.
The problem I’m having revolves around getting my application to authenticate. I display the login view to the user, and after they input their credentials, try and handle the redirect URL using a method implementation in my app delegate.
When I trace the series of calls throughout MyApp->Soundcloud API -> Oauth2Library during debugging, I can see that soundcloud accepts the credentials, and passes back the authorization_code which I then understand I’m supposed to use to request a session authentication token.
However when ‘handleOpenURL’ (in my AppDelegate) gets called, it fails to process the redirect and returns a 401 error whenever I try to gather user data (such as sending a call to [scAPI meWithContext:@"userInfo"]).
I’ve absolutely scoured these forums, and cannot seem to find the answer to my problem. I did however, stumble upon something that I think might be part of the case on the google groups forums for Soundcloud API support.
Another API user encounters a 401 response code (unauthorized), and describes a difference in the way the oauth2 library manages the authorized header field in the redirect response from SoundCloud between iOS 4 and iOS 5, and I am thinking this may be part of the issue.
The 401 response code has a localized description of NXOAuth2HTTPErrorDomain, and also writes the message [NXOAuth2PostBodyStream open] Stream has been reopened after close to NSLog.
I can provide more information if need be. I’m also using charles to debug the HTTPS calls to Soundcloud, and am certain the request is being sent to the correct destination.
Any help / feedback would be much appreciated.
As Tobias mentioned, the cocoa-api-wrapper is not supported anymore. I ran into the same problem, and since I needed streaming functionality as well, I forked the CocoaSoundCloudAPI to add streaming support from the cocoa-api-wrapper.