Mobile Dev: Why YouTube Embeds Started Failing in Our App (Error 15/153) and What We Did
About a month ago, we noticed that embedding YouTube videos in our mobile app (iOS & Android) started returning Error 15 or Error 153. These embeds had been working for years with no code changes on our side.
We discovered that many other developers were seeing the same error, especially in webviews inside apps, so the timing was curious.
The likely cause
It appears that YouTube’s embed policy enforcement has tightened: if the embed request originates from an app or webview that does not supply a validReferer or Origin, YouTube may refuse to play the video (hence the 15/153 error codes).This meshes with policy guidance in the YouTube “Required Minimum Functionality” documentation, which states that apps must provide certain identifying information including origin. Source: Google for Developers
Additionally, many mobile WebView implementations (on iOS & Android) often send an empty or missing referer header by default, which then leads to this embed rejection.
Our fix
For our Flutter-based app, we applied this remedy:
-
In the WebView that hosts the YouTube embed, explicitly set the
Referer(orOrigin) header to the app’s bundle ID or the hosting domain. -
For Flutter apps: we used the
package_info_pluspackage to obtain the application ID:Then passed
applicationIdinto the WebView request headers. -
We also considered using
youtube-nocookie.comdomains (which some communities suggested) but found that view tracking was unreliable and the behaviour was inconsistent across devices, so we reverted to standard domains + properRefererheader.
Final thoughts
If you have a mobile or embedded web-viewed app that surfaces YouTube videos, this change might suddenly break your embeds. The fix is to ensure your embed environment supplies the Referer or Origin header even if you didn’t previously.
For us, this change restored functionality almost immediately. It’s a small change but prevented a major disruption.
Comments
Post a Comment