Cookie issue in Exoplayer
How can I send signed cookie in exoplayer for AWS signed URL?
- I tried this method defaultHttpDataSourceFactory.setDefaultRequestProperty("X","Y"); But its not working.
Here is my code snippest:
defaultHttpDataSourceFactory.setDefaultRequestProperty("CloudFront-Expires", "1530921600"); defaultHttpDataSourceFactory.setDefaultRequestProperty("CloudFront-Signature", "signature of cloud front url"); defaultHttpDataSourceFactory.setDefaultRequestProperty("CloudFront-Key-Pair-Id", "APKAIXMG35SLRNPUHOPA");
Issue description
Source error. com.google.android.exoplayer2.upstream.HttpDataSource$InvalidResponseCodeException: Response code: 403 at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:211) at com.google.android.exoplayer2.upstream.DefaultDataSource.open(DefaultDataSource.java:137) at com.google.android.exoplayer2.upstream.DataSourceInputStream.checkOpened(DataSourceInputStream.java:102) at com.google.android.exoplayer2.upstream.DataSourceInputStream.open(DataSourceInputStream.java:65) at com.google.android.exoplayer2.upstream.ParsingLoadable.load(ParsingLoadable.java:114) at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:315) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764)
Have a look at Android's CookieManager, which is used by DefaultHttpDataSource for cookie management. With a bit of exploration you will manage to set cookies. How to authenticate to AWS is out of the scope of the issue tracker, unfortunately.
It is working on 7.0 and above but not woking on 6.0 and below. Any update on it?
I cannot find any information about cookie management bugs on Android. You could start debugging by checking that the lack of authentication token cookies is actually the cause of the 403. To do this, you could intercept the generated http headers using a developer tool. If the cookies are actually being sent correctly, and the headers look fine, then the next step would be checking that the app is not messing app authentication at some point. For example by changing the cookie manager.
I got the solution and its working in all devices even in kitkat also.