Search code examples
iosswifttwittersttwitter

iOS Twitter OAuth 1.0 returning login/error after authorize instead of callback url


I'm trying to use twitter's oath 1.0 via STTwitter cocoa pod to get a user access token as described here https://developer.twitter.com/en/docs/tutorials/authenticating-with-twitter-api-for-enterprise/oauth1-0a-and-user-access-tokens. I have a twitter developer app approved with a callback url configured in a similar format https://twitter.example.com. From what I understood the expected behaviour would be to go through these steps to get the oauth_verifier at the last step.

1) https://api.twitter.com/oauth/authorize?oauth_callback_confirmed=true&oauth_token_secret=SOMESECRET&force_login=1&oauth_token=SOMETOKEN
2) https://api.twitter.com/oauth/authorize
3) https://twitter.example.com/?oauth_token=SOMETOKEN&oauth_verifier=SOMEVERIFIER

Instead what I'm currently getting is an error after step 2 and no redirect url back at all. The last step redirects to this login page on my web view. In this case I even double checked if the user credentials were correct by logging on twitter's website directly.

1) https://api.twitter.com/oauth/authorize?oauth_callback_confirmed=true&oauth_token_secret=SOMESECRET_login=1&oauth_token=SOMETOKEN
2) https://api.twitter.com/oauth/authorize
3) https://twitter.com/login/error?username_or_email=SOMEEMAIL&redirect_after_login=https%3A%2F%2Fapi.twitter.com%2Foauth%2Fauthorize%3Foauth_token%SOMETOKEN

step 2 step 3


Solution

  • I have found the issue and it was related to WKWebview paste with keyboard paste text twice the password input, thus causing an authentication failure on twitter.

    https://developer.apple.com/forums/thread/696525