Twitter Timeline broken

Problem statement

In my Streamlit cloud page I display 2 Twitter timelines. Last week everything was okay and the timelines were working well. Yesterday I check again to see if everything was ok and I see that the timelines were not working. Instead of the Twitter timeline there was just a link to the twitter page (which worked on Chrome but not on firefox)

The code I use to built the Twitter timeline is:

class Tweets:
    def __init__(self, s, embed_str=False):
        if not embed_str:
            api = "https://publish.twitter.com/oembed?url={}".format(s)
            response = requests.get(api)
            self.text = response.json()["html"]
        else:
            self.text = s
            
    def displayEntity(self):
        components.html(self.text, height = 500, scrolling=True)

Then in the page I do this:

.....
tweet1 = Tweets("https://twitter.com/nbastats")   #for example
.....

And a Twitter Timeline should appear on the screen. This whole thing was working until some days ago.
The “console” of the browser shows this error:

Refused to execute script from 'https://cdn.syndication.twimg.com/timeline/profile?callback=__twttr.callbacks.tl_i0_profile_NBA_old&dnt=false&lang=en&screen_name=NBA&suppress_response_codes=true&t=1860531&tz=GMT%2B0100&with_replies=false' because its MIME type ('') is not executable, and strict MIME type checking is enabled.

Pls help

Have you checked the latest news about Twitter’s api?

1 Like

Oh I did not… Thank u for that! Now I understand why it is not working :cry:

1 Like

:bird: :fire: :wave: :slightly_frowning_face:

So there is no way around it?..

I asked in the twitter community and a dev said that:

Do you have a context security policy defined for your site?

If so you want to add the following domains to allow iframe-src

Is there something I can do? Like, is there a way to add those domains the CSP?

I’m not sure…I have not ever tried to tweak that…

Hey, mmm just quick thing! Good news for all!

Recently me and other people asked a twitter dev about this problem and today the guy fixed the problem, so now everything is working correctly :3

1 Like