1

https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/permission_delete?view=odsp-graph-online

Note: The @microsoft.graph.downloadUrl value is a short-lived URL and can't be cached. The URL will only be available for a short period of time (1 hour) before it is invalidated.

In the tutorial, the download url expires after an hour. How do I get a permanent download address?

error Message

Sorry, something went wrong The access token has expired. It's valid from '11/11/2020 1:18:52 AM' and to '11/11/2020 2:18:52 AM'.

김세림
  • 291
  • 1
  • 5
  • 17
  • Do you mean that the access token becomes unavailable after 1 hour? – Carl Zhao Nov 16 '20 at 03:17
  • @CarlZhao Sorry, something went wrong The access token has expired. It's valid from '11/11/2020 1:18:52 AM' and to '11/11/2020 2:18:52 AM'. – 김세림 Nov 16 '20 at 04:18
  • When I click the download url I get that error. – 김세림 Nov 16 '20 at 04:18
  • Hmm... This is a very common error. The lifetime of an access token is 1 hour. Have you tried to use the refresh token to obtain a new access token, or customize the lifetime of the access token? – Carl Zhao Nov 16 '20 at 05:51
  • @carlZhao https://learn.microsoft.com/en-us/graph/api/resources/driveitem?view=graph-rest-1.0 I only received the download url after request. – 김세림 Nov 16 '20 at 06:01
  • Please try the same as suggested above by Carl. You need to use the refresh token to obtain a new access token or customize the lifetime of the access token. Here's the doc - https://learn.microsoft.com/en-us/azure/active-directory/develop/access-tokens – Dev Nov 17 '20 at 08:23

2 Answers2

0

"The lifetime of an access token is 1 hour. Have you tried to use the refresh token to obtain a new access token, or customize the lifetime of the access token?"

Please try the same as suggested above by Carl. You need to use the refresh token to obtain a new access token or customize the lifetime of the access token. Here's the document.

Dev
  • 2,428
  • 2
  • 14
  • 15
  • https://learn.microsoft.com/en-us/graph/api/driveitem-createlink?view=graph-rest-1.0&tabs=http We created a share link and made it possible to download it with WebUrl. Tokens could not be obtained because anonymous users had to be able to download them. – 김세림 Nov 20 '20 at 04:23
0

Note: The @microsoft.graph.downloadUrl value is a short-lived URL and can't be cached. The URL will only be available for a short period of time (1 hour) before it is invalidated. Removing file permissions for a user may not immediately invalidate the URL.

The workaround was to create a share link for DriveItem and use the WebUrl as the result of the response. The file was accessed and made available for download through WebUrl. It seemed that the only way for non-tenant users to access it.

enter image description here

김세림
  • 291
  • 1
  • 5
  • 17