cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Share your feedback on the Document Scanning Experience in the Dropbox App right here.

Discuss Dropbox Developer & API

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

Get a folders public link using the dropbox API in Azure logic apps

Get a folders public link using the dropbox API in Azure logic apps

Jeff B.63
Collaborator | Level 8
Go to solution

We use Dropbox to store pictures from every jobsite we work on.  The estimator puts his pics in the folder for the crews to view and later the crews put their images in the same folder.  I have been using an Azure logic app to create the folders I need by using a constructed folder path and creating a txt file. I then delete the file afterwards.   But I can't find any way to get the public link for the folder using Logic Apps. 

 

 

I can do it in Zappier but that just gets stupid expensive in short order. 

 

Has anyone found a way to get the public link?

24 Replies 24

Jeff B.63
Collaborator | Level 8

Worked perfectly, Thank you.  do I now just use the refresh token as the access token in all of my http calls?

Authorization: Bearer <Refresh token>

Здравко
Legendary | Level 20

@Jeff B.63 wrote:

Worked perfectly, Thank you.  do I now just use the refresh token as the access token in all of my http calls?

Authorization: Bearer <Refresh token>

No, no, no,... definitely NO!

Refresh token doesn't replace access token, neither opposite! The refresh token is only used for refreshing (regenerating in fact) access token, nothing more. As I mentioned there (and as seems you skipped) in regular API calls valid access token (non expired - within the timespan as described) should be use. If needed (after currently used token expires), execute the last call in my description before next regular API call. :backhand_index_pointing_up:

Hope it's a bit more clear now.

Jeff B.63
Collaborator | Level 8

Thank you for your help Здравко,  I read your other directions more clearly and it worked great. 

 

My next challenge was how to use the refresh token in my Logic App.  After an awful lot of searching, I was able to cobble something together.

For anyone else finding this thread, I will include that information for them below:

 

  1.  I had to set up blob storage in Azure and set any flows to use a system managed identity with the role of "Storage Blob Data Reader".
  2.  I then set up a new Logic App with a Recurrence Trigger set to 5 mins (or whatever you want) with the role of "Storage Blob Data Owner".
  3. I added a file to the storage and use that same name throughout, say DBtoken.txt. 
  4. I retrieve the blob metadata and use a condition to check if utcNow() > (LastModified timestamp + 4 hrs).
  5. False does nothing
  6. True then runs an HTTP action using the refresh token to get a new 4hr token:Screenshot 2024-02-03 173633.png
  7. Then I save the blob back into the storage using the same filename as before - DBtoken.txt
  8. Now any Logic Apps I want to have access to the Dropbox API can do so by reading the blob and getting the current access token.  I'll describe that here:
  1. Initialize a boolean variable called Token_Expiry 
  2. Retrieve the blob data from the blob storage
  3. Insert an Until function that runs until Token_Expiry is = to True
  4. Add a Condition inside the Until that check if utcNow() <= (Last Modified + 4hrs)
  5. False does nothing
  6. True has three actions: get blob content, parse json of blob content and sets Token_Expiry to True
  7. Finally, right after the Until, I initialize a variable to hold the current token and use it in the HTTP Dropbox API actions I have later in the flow.

Maybe there is a simpler way to do this but this is all I could figure out with my very limited knowledge.

Здравко
Legendary | Level 20

Hi @Jeff B.63,

Congratulations to you for your solution! :slightly_smiling_face: I believe your sharing will help many other people working on the same environment.

There are some imperfections though that push your solution to the border of stability. There is small but real chance some of your API calls to fail authentication! Of course in such a situation the details are important (something I don't know), but in all cases minimizing assumptions in the code is a good idea (they may play bad game :smiling_face_with_horns:).

 


@Jeff B.63 wrote:

...

    4. I retrieve the blob metadata and use a condition to check if utcNow() > (LastModified timestamp + 4 hrs).

...


When something is NOT guaranteed in any way better don't rely on! Yes, typically access token validity period is 4hr, but again typically NOT mandatory (may be less). I gave it just as example, nothing more. I mentioned in explicit way that validity is denoted in "expires_in" field. You're ignoring this value in favor of assumption! In addition it's good idea to "cut" 2, 3, or 5 mins out from validity period, cosa there are always some delays in token receiving, calculations, etc. - something that accumulates and can... make your check wrong (and you code tries work with just expired token in some cases).

 


@Jeff B.63 wrote:

...

    7. Finally, right after the Until, I initialize a variable to hold the current token and use it in the HTTP Dropbox API actions I have later in the flow.

...


Hm...:thinking_face: How long is this flow of actions? Is there any chance for your token expiration meantime? Important detail! It's good idea to check for token validity at the beginning of every API call, not at the beginning of flow of calls - just to make the things more secure. Even more in such a way you don't need additional trigger - the call, you're going to do, itself is a trigger. :winking_face:

Good luck to you and all others interested.

Jeff B.63
Collaborator | Level 8

Thank you for that input, I will work on that and revise the post.  I put the loop in place so that if there was delay in getting the new token the loop would continue until the token was available. But I understand your concerns and will add a reference to the validity period in the blob and use it in the condition instead of just 4 hour minus a few minus of course.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Jeff B.63 Collaborator | Level 8
  • User avatar
    Здравко Legendary | Level 20
What do Dropbox user levels mean?