Firebase storage access token gets removed when passed as a parameter to firebase dynamic link

Viewed 264

I've stored an audio file in firebase storage and I want to pass its url with access token as a parameter to the firebase dynamic link.

I wan to make my file.component,ts available for public share on whatsapp, FB etc and below is the code where I am getting the file parameters

this.activatedRoute.queryParams.subscribe(params => {
      this.userName = params["user"];
      this.audioPath = params["audio"]; //firebase storage audio with access token
      this.docId = params["docId"];
      this.docTitle = params["title"];
      this.userId = params["userId"]; 
)

Now I want to pass all the above parameters as a link to the firebase dynamic link http.post call to get a short link.

The audio parameter consists of url to firebase storage access url along with the access token e.g

https://firebasestorage.googleapis.com/v0/b/<site>/o/audio%2Fsong1-min.mp3?alt=media&token=xxxx-xxxxx-xxxx-xxxxx

The moment I pass this audio variable to the dynamic link, it removes the token and reduces the path to

https://firebasestorage.googleapis.com/v0/b/<site>/o/audio%2Fsong1-min.mp3

Hence when I receive the short link it displays all other fields on UI along with the audio tag but the src has the token removed hence external user cannot play the audio if shared on whats app, FB etc.

Is there anyway I can send this firebase storage access url as it is inside the dynamic link so that the audio could play.

2 Answers

I don't believe this is possible in the way you are designing it, Firebase Dynamic Links will take out the token to shorten the link and there is no way to force it not to do it. What you could do is either:

1 - Make the File publicly readable;

2 - Have the file be fetched and processed separetly in your app without using Firebase Dynamic Links;

The problem may be linked to the method that you use to generate the Dynamic Links. The longDynamicLink method of the firebase REST API seems to exclude tokens, but the dynamicLinkInfo seems to keep them, so try that latter instead.

The following error message pops up when using the longDynamicLink approach with a token:

{ warningCode: 'UNRECOGNIZED_PARAM', warningMessage: "Unrecognized param 'token'. [https://firebase.google.com/docs/dynamic-links/create-manually#ddl_parameters]" }

Related