Twitter's Twitter strategy requires a user to be signed in to Twitter and allow your โapplicationโ to allow access to your Twitter account. This cannot be done using XHR, because how can a user enter their Twitter credentials to log in to Twitter if the user has not been signed up yet? How will the user approve the permissions that your Twitter โappโ requests if the request is sent via XHR?
This applies to all Passport strategies that use OAuth or OpenID. The user browser must go directly to the site of the authorization provider so that it can either A) log into the auth provider or B) approve the permissions requested in your application. As soon as the user does what the auth provider (in your case Twitter), it redirects the user's browser back to the endpoint of your application using its token, which your application will then use to request information from the authorization provider (e.g. email address, full name, etc.)
source share