# How to download video for offline with cookies in Android Bitmovin player using OfflineContentManager

**URL:** <https://community.bitmovin.com/t/how-to-download-video-for-offline-with-cookies-in-android-bitmovin-player-using-offlinecontentmanager/2870>\
**Category:** Support\
**Tags:** bitmovin-player, android, bitmovin\
**Created:** [May 2, 2024, 1:20pm UTC](https://community.bitmovin.com/t/how-to-download-video-for-offline-with-cookies-in-android-bitmovin-player-using-offlinecontentmanager/2870 "2024-05-02T13:20:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ankurrathe](https://avatars.discourse-cdn.com/v4/letter/a/e0b2c6/32.png) [@ankurrathe](https://community.bitmovin.com/u/ankurrathe)\
**Post date:** [May 2, 2024, 1:20pm UTC](https://community.bitmovin.com/t/how-to-download-video-for-offline-with-cookies-in-android-bitmovin-player-using-offlinecontentmanager/2870/1 "2024-05-02T13:20:43Z")

</div>

We are using Bitmovin version 3.48.0 in our project.

**projectMinSdkVersion** = 23  
**projectTargetSdkVersion** = 33  
**projectCompileSdkVersion** = 33

We want to download the secured video content which is saved in chunks over server and to access the secured video content we are using below mentioned cookies.

I would like to know how to use or pass cookies to download this secured video content using bit movie player.

```auto
Map<String, List<String>> map = new HashMap<>();

map.put(" **Policy**", new ArrayList<>(Collections.singleton(mediaCookies.getMediaCookie().getCloudFrontPolicy())));
map.put(" **Signature**", new ArrayList<>(Collections.singleton(mediaCookies.getMediaCookie().getCloudFrontSignature())));
map.put(" **Key-Pair-Id**", new ArrayList<>(Collections.singleton(mediaCookies.getMediaCookie().getCloudFrontKeyPairId())));

SourceConfig config = new SourceConfig(cookiesUrl, SourceType.*Hls*);
config.setTitle(offlineDocuments.getVideoTitle());
config.setPosterSource(offlineDocuments.getThumbnailUrl());
config.setDescription(offlineDocuments.getSummary());

offlineContentManager = OfflineContentManager.getOfflineContentManager(
config,
offlineAppVideoPath,
videoUID,
listener,
getApplicationContext()
);

```

```auto
Task failed: application/x-mpegURL:/data/data/com.android.package.debug/offline/video/TURVMU5UUTJOVWhWVldaa1ltSmxZZw0:0:1, false
                                                                                                      com.google.android.exoplayer2.upstream.HttpDataSource$InvalidResponseCodeException: Response code: 403
                                                                                                          at com.google.android.exoplayer2.upstream.DefaultHttpDataSource.open(DefaultHttpDataSource.java:419)
                                                                                                          at com.bitmovin.player.core.p0.r.open(SourceFile:4)
                                                                                                          at com.bitmovin.player.core.p0.e.open(SourceFile:16)
                                                                                                          at com.google.android.exoplayer2.upstream.TeeDataSource.open(TeeDataSource.java:60)
                                                                                                          at com.google.android.exoplayer2.upstream.cache.CacheDataSource.openNextSource(CacheDataSource.java:802)
                                                                                                          at com.google.android.exoplayer2.upstream.cache.CacheDataSource.open(CacheDataSource.java:615)
                                                                                                          at com.google.android.exoplayer2.upstream.cache.CacheWriter.readBlockToCache(CacheWriter.java:180)
                                                                                                          at com.google.android.exoplayer2.upstream.cache.CacheWriter.cache(CacheWriter.java:142)
                                                                                                          at com.google.android.exoplayer2.offline.SegmentDownloader$SegmentDownloadRunnable.doWork(SegmentDownloader.java:509)
                                                                                                          at com.google.android.exoplayer2.offline.SegmentDownloader$SegmentDownloadRunnable.doWork(SegmentDownloader.java:486)
                                                                                                          at com.google.android.exoplayer2.util.RunnableFutureTask.run(RunnableFutureTask.java:130)
                                                                                                          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
                                                                                                          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
                                                                                                          at java.lang.Thread.run(Thread.java:1012)

```

Thanks

---

<div class="post-metadata">

**Author:** ![kazuhide](https://sea1.discourse-cdn.com/flex015/user_avatar/community.bitmovin.com/kazuhide/32/263_2.png) [@kazuhide](https://community.bitmovin.com/u/kazuhide)\
**Post date:** [May 31, 2024, 2:11am UTC](https://community.bitmovin.com/t/how-to-download-video-for-offline-with-cookies-in-android-bitmovin-player-using-offlinecontentmanager/2870/2 "2024-05-31T02:11:00Z")

</div>

Hi @ankurrathe

Thank you for contacting the Bitmovin Community.

Regarding your question about using cookies on Android, we have a tutorial available. Please refer to it to see if it meets your requirements:

[How to send cookies along with requests in the Player SDKs](https://developer.bitmovin.com/playback/docs/how-to-send-cookies-along-with-requests-in-the-player-sdks#android-android-tv-and-amazon-firetv).

As a test, when I included the following test data as cookies in the source URL along with the tutorial’s CookieManager configuration, the cookies were successfully sent:

```auto
val sourceUrl = "https://your-source-url.mpd"

// Example test data for cookies
val map: Map<String, List<String>> = mapOf(
    "Policy" to listOf("testPolicy"),
    "Signature" to listOf("testSignature"),
    "Key-Pair-Id" to listOf("testKeyPairId")
)

for ((key, valueList) in map) {
    for (value in valueList) {
        val cookie = HttpCookie(key, value)
        DEFAULT_COOKIE_MANAGER.cookieStore.add(URI(sourceUrl), cookie)
    }
}

```

Hope this method provides a solution for you. If you have any further questions, please let us know. Thank you.

Best Regards,  
Kazuhide
