I'm using the rclone wrapper rclone.js to use rclone inside my nuxt3 app. It's working well but so far the only way I found to make it work is to update manually the ondrive token inside the config file.
which look like this in /Users/me/.config/rclone/rclone.conf
[onedrive]
type = onedrive
client_id = xxxxxxxxx
client_secret = xxxxxxxx
drive_type = business
drive_id = xxxxxxxx
access_scopes = Files.Read Files.Read.All Sites.Read.All offline_access
link_scope = organization
token = {"token_type":"Bearer","expires_in":3599,"ext_expires_in":3599,"access_token":"xxxxxxxxxx"}
I don't see any doc on how to update this token programmatically.
Here is my code that sync my files, for reference:
// Import promises from default rclonePkg
import rclonePkg from 'rclone.js'
const { promises: rclonePromises } = rclonePkg
export default defineEventHandler(async (event) => {
try {
const { onedriveFolder } = await readBody(event)
const output = await rclonePromises.sync(`onedrive:${onedriveFolder}`, `cloudflare:${process.env.CLOUDFLARE_BUCKET}`, {
env: {
RCLONE_CONFIG: process.env.RCLONE_CONFIG
}
})
return {
statusCode: 200,
body: `Sync completed successfully!`
}
} catch (error) {
console.error(error)
}
})
I know how to get the token from onedrive but I don't know how to update rclone config
Any idea?