Skip to content

Incorrect downloadToken used to access storage item #6882

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
steveoh opened this issue Dec 13, 2022 · 3 comments
Closed

Incorrect downloadToken used to access storage item #6882

steveoh opened this issue Dec 13, 2022 · 3 comments

Comments

@steveoh
Copy link

steveoh commented Dec 13, 2022

[REQUIRED] Describe your environment

  • Operating System version: mac os 11.6.8
  • Browser version: chrome 108.0.5359.98
  • Firebase SDK version: 9.15.0
  • Firebase Product: storage

[REQUIRED] Describe the problem

i'm using an upstream package called reactfire to use this lib with hooks etc for react. I'm trying to debug an issue where the downloadToken for an image is not correct when using the useStorageDownloadURL hook. This appears to ultimately call into the firebase-js-sdk and the ref's getDownloadURL method. This then calls into another getDownloadURL in storage. Then downloadURLHelper get's involved and finally downloadUrlFromResourceString constructs the url.

What i'm finding is that getDownloadUrl is not using the correct token. It's like it gets cached or it's not getting set properly.

As you can see here

image

The token used from downloadTokens in the request is quite different from what was returned from the server.

Steps to reproduce:

  1. Upload an image.
  2. Request the images url to show it on the web
  3. Delete the image
  4. Upload a new image to the same storage location
  5. Request the images url to show it on the web
  6. Request fails with a 403 since the wrong access token was used

Relevant Code:

// I can provide code but it's a few levels away from the source...

refs #FirebaseExtended/reactfire#565

@maneesht
Copy link
Contributor

I tried the following and couldn't reproduce. Am I missing something?

    const myRef = ref(storage, 'storage.txt');
    await uploadBytes(myRef, file);
    await getDownloadURL(myRef);
    await deleteObject(myRef);
    await uploadBytes(myRef, file2);
    console.log(await getDownloadURL(myRef));

@steveoh
Copy link
Author

steveoh commented Dec 14, 2022

I do not think you are missing anything. Boiled down that's basically what i'm doing.

It's hard for me to understand how this is happening.

@steveoh
Copy link
Author

steveoh commented Dec 14, 2022

Seems to work without the react fire hooks so I'll stick with that.

@steveoh steveoh closed this as completed Dec 14, 2022
@firebase firebase locked and limited conversation to collaborators Jan 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants