Skip to content
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

Allow authentication token to be passed to React components #172

Closed
devcjohn opened this issue Aug 29, 2022 · 4 comments
Closed

Allow authentication token to be passed to React components #172

devcjohn opened this issue Aug 29, 2022 · 4 comments

Comments

@devcjohn
Copy link

For our use case, we would like to generate an authentication token on our Node backend, then pass it to our React frontend to be used with the AdvancedImage react component.

It's a similar as this one from the legacy React package:
cloudinary/cloudinary-react#242

Ideally it would look something like this:

  <AdvancedImage cldImg={img} plugins={[responsive(), accessibility()]} token={token} />
@igy
Copy link

igy commented Aug 31, 2022

Hi Chuck,

Thanks for contacting us.

We've created a feature request for our SDK team to consider when planning the future roadmap for the SDK.
If there are any updates or if we have an ETA by which this could be added, we'll add a note here with the details.

In the meantime, alternatives for using Access Control are to enable delivery via your own hostname, so the token can be sent in a cookie, or create the delivery URLs using another method (such as the js-url-gen project) and then adding the URLs via another method.

It may also be possible for you to fork the SDK and add support for this yourself, though we generally recommend using the published SDK versions, because if a bug are found in an SDK version, we'll need to make a new release to resolve ot and your own changes could be incompatible with the new version, preventing you from upgrading to resolve the bug.

Regards,
Stephen

@igy
Copy link

igy commented Apr 11, 2023

Hi Chuck,

Following up on this, the @cloudinary/url-gen library was recently updated to allow passing query string parameters to the URLs it creates, which will allow you to pass tokens when loading assets via our frontend frameworks.

If you update your dependencies to use 1.10.0 of that library, you can pass queryParams as an option when instantiating CloudinaryImage, and the parameters will be added to the URL used by the component.

There's a simple usage example available here, though to actually use token authentication you'll need to retrieve the token from your server-side code before this: https://codesandbox.io/s/morning-voice-vnt3in?file=/src/App.js

Regards,
Stephen

@devcjohn
Copy link
Author

Thanks @igy

I am no longer on that team to verify this improvement, but I will make sure they're aware of this.

@cloudy408
Copy link
Contributor

Hi Chuck,

Thank you for doing that. If there are any further questions or comments we can answer them here!

Regards,
John

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants