bdbergeron / BDBOAuth1Manager

OAuth 1.0a library for AFNetworking 2.x
MIT License
100 stars 35 forks source link

Cocoapods install wrong version #7

Closed mantas closed 10 years ago

mantas commented 10 years ago

Hi,

For some reason I got 1.0.2 from cocoapods. I had to add repo addresss to Podfile to get 1.0.4.

On a separate note, I bumped into a trouble while debuging my code. If request token is already downloaded and app tries to download it again, it gives "Request failed: unauthorized (401)" error. It took me a while to figure out why I was getting this error. Did you considered adding a check to fetchRequestToken method? Smth like snippet bellow would help a lot:

if(self.isAuthorized){
    @throw([NSException exceptionWithName:@"Duplicate token request" reason:@"Can't fetch request token twice. Please deauthorize before fetching a new token" userInfo:nil]);
}
bdbergeron commented 10 years ago

Make sure you do a pod repo update command every now and then to verify that your CocoaPods master repo is up-to-date.

Whether or not the application has already been authorized is something that you as a developer should check before calling fetchRequestTokenWithPath:. Take a look at the included demo apps to get a good idea of the workflow. The request token, however, is a different thing, and that's what is causing this error. Although I'm not sure why one would ever call fetchRequestTokenWithPath: again after it succeeds and before calling fetchAccessTokenWithPath:, any existing request token should be cleared before trying to fetch a new one. If it is not, the existing request token will be sent via the HTTP headers when requesting a new one, thus why you're receiving a 401 Unauthorized error.

I've added the quick one-line fix, and it will be pushed to CocoaPods on the next release.