nst / STTwitter

A stable, mature and comprehensive Objective-C library for Twitter REST API 1.1
BSD 3-Clause "New" or "Revised" License
999 stars 161 forks source link

Attempting to verify Twitter authentication PIN fails everytime if the user has entered PIN incorrectly once. #250

Closed siburb closed 8 years ago

siburb commented 8 years ago

If the user enters the PIN correctly the first time, then it works perfectly. However, if they enter incorrectly the first time and then correctly the second time, the authentication always fails with a 401.

We have the STTwitterAPI object as a strong property and are checking that it is non-nil before using the postAccessTokenRequestWithPIN: method (we re-init it if it is nil). All seems fine, but it is always failing following an incorrect PIN.

We've noticed something similar when using the postTokenRequest: method a second time - it always works the first time, but fails if we try to call it twice during the session.

We're on a tight schedule with this, so if anyone can help with this it would be much appreciated.

nst commented 8 years ago

I'm sorry to read about this issue.

Entering a wrong PIN before the right PIN won't work, this is the way Twitter API is.

As a workaround, you may want to create a new instance of your STTwitterAPI object when receiving 401.

Now, there is still a bug in STTwitter. You should be able to call postTokenRequest: a second time.

Now I found the bug a fixed it. Can you please confirm that it works for you?

siburb commented 8 years ago

Thanks so much @nst! With the fix, I can now request a new URL after a receiving a 401 when attempting to authenticate.

I think that just creating a new instance of the STTwitterAPI object fixes general problems with requesting a new URL (e.g. for a refresh button).

Anyway, I really appreciate your help! We're using STTwitterAPI in an AppleTV app that's going to launch in a few weeks and it is working beautifully. My fork of the repo has been updated a fair bit (https://github.com/siburb/STTwitter), would be good to hear what you think of the changes, and see if they'd be useful to pull across.