Search code examples
node.jsonedriveadal

Connect to OneDrive using a daemon app in node.js


I'm trying to create a script which connect to OneDrive (consumer) in order to get some file. However, between consumer and enterprise and all those different azuread stuff I'm lost.

Is there a simple explanation on how do I get a token to access OneDrive in a daemon app?


Solution

  • To interact with OneDrive for the personal account, we can use the Microsoft Graph via acquiring the token form Azure AD V2.0 endpoint.

    However, this endpoint doesn't support such scenario. The client credentials flow for Azure AD v2.0 endpoint only work for the organizational account.

    As a workaround, you may consider get the access token and refresh token via the code flow and then using the refresh token to renew the access token. And you need to acquire the refresh token before it is expired. And based on the document the lifetime of refresh token for the personal account is up to 1 year(refer here).

    And to acquire the access token and refresh token for OverDrive personal account you can refer the code flow from this document.