简体   繁体   中英

PHP Script downloading specific file from OneDrive

My friend shared a folder on OneDrive with me - his script daily puts there a file named like <name>-dd-mm-yyyy.ext . I'd like to download this file to an Android application (since files are added daily, there is no persistent URL)

My idea is to write PHP script on my hosting, which will download this file daily and then publish, such that I'll be able to download it from my server with fixed name.

However, all examples of using PHP Microsoft Graph API involves asking user to log in. Since this script will be started periodically by scheduler, obviously, there won't be a way to enter credentials. And I have access to these files, because they are shared with me, so I'd access my own account only.

Is there a way to write PHP script, which will download files accessible from my account without need to authorize access each time?

You should be able to use the refresh token which you get as part of the response from the OAuth 2 token endpoint. Refresh tokens, unlike access tokens, are long lived and can be used to acquire access tokens once they expire. You can read more about refresh tokens here:

https://developer.microsoft.com/en-us/graph/docs/concepts/auth_v2_user#5-use-the-refresh-token-to-get-a-new-access-token

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM