Helix OneDrive CLI
Project Helix OneDrive Command Line Interface Utility
$ npm install @adobe/helix-onedrive-cli
Usage: 1d <command> Commands: 1d me Show information about the logged in user. 1d login Start the login interactive flow or ROPC flow with username / password. 1d logout Logout be removing the authorization file. 1d resolve <link> Resolves a share link to the respective drive item. 1d ls [path] Lists the contents of the [path] 1d get <path> [local] downloads the file at path 1d put <local> [path]] upload the local file. Options: --version Show version number --verbose, -v Run with verbose logging --help Show help
The 1d client runs with a default client id which supports interactive login. Just run
1d login, copy paste the authorization code in the browser and sing into microsoft.
If you want to run the client with different parameters, you can provide
.env file containing the azure client-id and client-secret of your app.
# azure app oauth secrets AZURE_APP_CLIENT_ID="11111111-1111-1111-1111-11111111111" AZURE_APP_CLIENT_SECRET="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
.env is setup, start the dev server with:
$ npm start
and open a browser at: http://localhost:4502/.
click on the link to login. after successful login to microsoft, the server writes a
.auth.json on disk.
After that you can stop the server, and use the cli, eg:
$ 1d me Logged in as: John Doe (email@example.com)
To reset authentication, just delete the
.auth.json file and open the browser in private mode.
Login with device token
In order to login with a device token, run:
$ 1d login To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code HNGP5CAF8 to authenticate. updated .auth.json file. $ 1d me Logged in as: John Doe (firstname.lastname@example.org)
Login with username / password
Some accounts and apps allow login with username and password (ROPC flow). Usually federated accounts require MFA, which disallow using ROPC.
$ 1d login --email@example.com password: **** updated .auth.json file. Logged in as: John Doe (firstname.lastname@example.org)
$ npm install
$ npm test
$ npm run lint