question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Twitter API OAuth 2.0 - CORS / Postmessage

See original GitHub issue

Hey guys,

We are currently working on implementing the Twitter API v2 and would like to authorize via the new OAuth 2.0 Authorization Flow.

Pretty much all OAuth Flows of other sites allow an in-browser callback, either by passing redirectUri="postmessage" in case of the Google Login, or by tracking the OAuth window via window.open and then checking if the URI has changed to grab the auth code from the params. This is import to give the user immediate feedback if the authorization was successful or not.

Unfortunately it looks like Twitter doesn’t allow either of these methods, and blocks any tracking of the opened authorization window via its CORS policy. While I completely agree that the CORS policy should be in place for any other API call (in order to prevent clients from calling the API directly within the browser), I definitely think that it should be loosened for the authorization endpoint (https://twitter.com/i/oauth2/authorize).

It’s taken Twitter quite a while to step away from the outdated 3-legged auth flow, so it’s pretty important to the get the OAuth 2.0 flow implemented properly so that developers can access it easily. So far there is no single gem out there that helps to implement the OAuth 2.0 flow for Twitter, simply because there is no good option to have a direct callback. Please consider allowing this to work the same like all other services.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
elie222commented, Aug 13, 2022

Estimated to be another 10 years. https://stackoverflow.com/a/35898961/2602771

1reaction
andypipercommented, Aug 7, 2022

This is useful information, thanks for sharing the other implementations. Definitely all still in flux but we appreciate the input and data.

Read more comments on GitHub >

github_iconTop Results From Across the Web

OAuth 2.0 Making requests on behalf of users | Docs
How to connect to endpoints using OAuth 2.0 Authorization Code Flow with PKCE ... curl --location --request POST 'https://api.twitter.com/2/oauth2/token' ...
Read more >
Issues · twitterdev/twitter-api-typescript-sdk - GitHub
Contribute to twitterdev/twitter-api-typescript-sdk development by creating an account on GitHub. ... Twitter API OAuth 2.0 - CORS / Postmessage.
Read more >
CORS error in oauth2/token? - Twitter API v2
I'm trying to authenticate users via OAuth 2.0 with PKCE on my singe-paged app. Requests to oauth/token endpoint seem to fail due to...
Read more >
OAuth 2.0 form post response mode - Connect2id
Adds support for implementing custom (experimental) OAuth 2.0 response modes, such as based on CORS Ajax or window.postMessage.
Read more >
Using CORS for Cross-Domain Ajax Requests
With the emergence of the Cross Origin Resource Sharing (CORS) ... called some-resource at otherdomain.com using the jQuery Ajax API, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found