cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more here.

Discuss Dropbox Developer & API

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Use API get image name from dropbox and display in html img tag

Use API get image name from dropbox and display in html img tag

rahulsharma1902
Explorer | Level 4

I get image name and id from drop box using api 
But now I don't know how I can use this image name in img tag can you give me a public url according to that I can display this image in my html <img> tag ?xnLTj4yQSPWeX271sA6Ljw.png

 

5 Replies 5

Здравко
Legendary | Level 20

@rahulsharma1902 wrote:

I get image name and id from drop box using api 
But now I don't know how I can use this image name in img tag ...


Hi @rahulsharma1902,

You can use this image name in img tag as far as you could for any other file from any other place 🙋 (i.e. you cannot).

 


@rahulsharma1902 wrote:

... can you give me a public url according to that I can display this image in my html <img> tag ?


You can use either /2/files/get_temporary_link or /2/sharing/create_shared_link_with_settings (whatever better match to your use case) or their SDKs equivalents (if you use some). Keep in mind that using shared link requires transformation from preview link (the default one) to raw link! Forgetting this will lead to unusable HTML.

Happy new year and hope this gives direction.

Greg-DB
Dropbox Staff

@rahulsharma1902 To add on to what Здравко said, if you need to modify a shared link, refer to this help article.

rahulsharma1902
Explorer | Level 4

I have more query :
1. I am using access token to get image link but the access token is expire within some hours how I get long term access token ?
2. Second one Is client give me client ID and secret Id and redirect URL  but when I use these credential in my device this give me error but when I replace these with my Dropbox app credential then they work fine ? should we use them in our device

Здравко
Legendary | Level 20

@rahulsharma1902, Dropbox API doesn't issue long lived access token anymore. All access token issuing at present are short lived and remain valid for 4 hours or so. For long term access, you need refresh token that doesn't expire automatic and can be used repeatedly whenever needed to "refresh" (regenerate actually) access token.

Don't mess application authentication and account (user) authentication (as you're doing)! They are different things and usually one of them cannot replace the other (as you're trying). Application authentication (app key and app secret) authenticates the application itself (as the name suggests), not some account (including the one associated with the application). Such authentication can be used only for activity unrelated to particular account content, but only to content public accessible already (like some shared links related operations). To perform account access, you need corresponding account related authentication that represent account owner granting for your application to manage the content (including your own) - access and refresh tokens.

You can let the user (again, including to yourself) to grant access permissions to your application to access owned account using OAuth flow (take a look here for a simplest example). In such a way your application ask the user for permission to access the content. Here you can Note offline access that will result in adding refresh token. If you're using some supported SDK initializing the client object properly using refresh token is enough (you don't need to perform refresh yourself), otherwise the last step in the post I linked to be comes your responsibility.

Hope this helps.

Greg-DB
Dropbox Staff

@rahulsharma1902 As Здравко said, Dropbox is no longer offering the option for creating new long-lived access tokens. Dropbox is now issuing short-lived access tokens (and optional refresh tokens) instead of long-lived access tokens. You can find more information on this migration here.

Apps can still get long-term access by requesting "offline" access though, in which case the app receives a "refresh token" that can be used to retrieve new short-lived access tokens as needed, without further manual user intervention. Refresh tokens do not expire automatically and can be used repeatedly. You can find more information in the OAuth Guide and authorization documentation. There's a basic outline of processing this flow in this blog post which may serve as a useful example.

 

If you still need help with any particular error, please share the relevant details so we can take a look.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    Здравко Legendary | Level 20
  • User avatar
    rahulsharma1902 Explorer | Level 4
What do Dropbox user levels mean?