Skip to content

Commit 22b9404

Browse files
Send authorization header for getSignedMediaToken conditionally
1 parent ada634c commit 22b9404

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
# [3.13.28] - 20-06-2024
6+
7+
### Fixes
8+
9+
- Send authorization header for `getSignedMediaToken` conditionally
10+
511
# [3.13.27] - 19-06-2024
612

713
### Changes

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@inplayer-org/inplayer.js",
3-
"version": "3.13.27",
3+
"version": "3.13.28",
44
"author": "InPlayer",
55
"license": "MIT",
66
"description": "A Javascript SDK for Inplayer's RESTful API",

src/endpoints/asset.ts

+8-9
Original file line numberDiff line numberDiff line change
@@ -849,26 +849,25 @@ class Asset extends BaseExtend {
849849
mediaId: string
850850
): Promise<AxiosResponse<SignedMediaResponse>> {
851851
const tokenObject = await this.request.getToken();
852+
const headers = {};
853+
854+
if (tokenObject.token) {
855+
headers['Authorization'] = `Bearer ${tokenObject.token}`;
856+
}
852857

853858
return this.request.get(API.getSignedMediaToken(appConfigId, mediaId), {
854-
headers: {
855-
Authorization: `Bearer ${tokenObject.token}`
856-
}
859+
headers
857860
});
858861
}
859862

860863
async getSiteEntitlements(
861864
siteId: string
862865
): Promise<AxiosResponse<SiteEntitlementsResponse>> {
863866
const tokenObject = await this.request.getToken();
864-
865-
const headers: Record<string, string> = {
866-
Accept: 'application/json',
867-
'Content-Type': 'application/json'
868-
};
867+
const headers = {};
869868

870869
if (tokenObject.token) {
871-
headers.Authorization = `Bearer ${tokenObject.token}`;
870+
headers['Authorization'] = `Bearer ${tokenObject.token}`;
872871
}
873872

874873
return this.request.get(API.getSiteEntitlements(siteId), { headers });

0 commit comments

Comments
 (0)