I try to use OAuth 2.0 Authorization Code Grant Flow on my iPhone, but the callback fails.

Reproduction

  1. Open the following link in the In-App browser. ttps://oauth-playground.glitch.me/?id=createTweet&compose=1 (removing h)
  2. Tap the “Run” button.
  3. Redirect to the Twitter official app automatically.
  4. Redirect to iOS default browser automatically.
  5. Authorize.
  6. Redirect to callback URL, but authorization has not been successful.

Guess

We use the “state” associated with the user agent for preventing CSRF attacks.
The state is associated with In-App browser in step 2, but the callback URL is opened by another user agent in step 6.

Since it is likely that a website using the Twitter API will be opened in a browser within an official Twitter app, we would like to be able to authorize it correctly.

Is there any way to ensure that the authorization is done correctly?

Hey, this seems to be a similar problem what @takke is experiencing here where the URL is captured by the wrong app:

2 Likes

Hi, @dewey.

I check the linked topic and it is a similar issue as you say.

In the web application, it seems to be worked to open in Safari or Chrome before starting the authorization flow as workground.

This issue has been acknowledged by Twitter’ OAuth team, so I look forward to improving it in the future.