This program connects to OneDrive to:
- List files
- Download files
- List all users who have access to a file
- Provides real-time updates on user access changes
This application implements Microsoft OAuth2 for secure login and authorization. Users will be prompted to log in with their Microsoft account, granting the application access to their OneDrive data. The OAuth2 flow ensures that user credentials are handled securely and that the application only accesses the resources explicitly permitted by the user.
-
Clone the repository:
git clone https://github.com/MayankAgrawal94/onedrive-poc.git cd onedrive-poc
-
Install dependencies:
npm install
-
Setup Environment Variables Create a
.env
file in the root directory ofonedrive-poc
and add the following environment variables, filling in the missing values:PORT=3001 BASE_URL=http://localhost:3001 AZURE_CLIENT_ID= AZURE_CLIENT_SECRET= AZURE_TENANT_ID= MS_AUTH_ENDPOINT=https://login.microsoftonline.com/common/oauth2/v2.0 MS_GRAPH_ENDPOINT=https://graph.microsoft.com/v1.0 SESSION_SECRET= #For internal 'express-session' configuration COOKIE_MAX_AGE=1 # in days
Note: When registering a new app in Azure, make sure to add the 'Redirect URI' as
{BASE_URL}/v1/auth/ms/cb
. -
Start the server:
npm run start
-
Open the client: Open
http://localhost:3001
in a web browser.
.
├── package.json
├── package-lock.json
├── README.md
└── src
├── app
│ ├── controllers
│ │ ├── auth
│ │ │ ├── basic.auth.controller.js
│ │ │ └── ms.auth.controller.js
│ │ └── msOneDrive.controller.js
│ ├── helpers
│ │ ├── genericFun.js
│ │ └── onedrive.js
│ ├── routes
│ │ ├── auth
│ │ │ ├── basicAuth.routes.js
│ │ │ └── msAuth.routes.js
│ │ └── msOneDrive.routes.js
│ └── services
│ ├── auth
│ │ ├── index.js
│ │ ├── oauthCallback.js
│ │ ├── oauthRequest.js
│ │ └── refreshToken.js
│ └── onedrive.js
├── app.js
├── config
│ ├── env.js
│ └── session.config.js
├── middleware
│ └── isAuthenticated.js
├── public
│ ├── assests
│ │ ├── document-icon.png
│ │ ├── download-icon.png
│ │ └── folder-icon.png
│ ├── index.html
│ ├── scripts
│ │ └── logic.js
│ ├── styles
│ │ ├── tree-container.css
│ │ └── welcome.css
│ └── welcome.html
├── server.js
└── socket.js
- Login with valid a OneDrive account and click the "Watch File" button.
- The permissions will be displayed and updated in real-time as they change.
If you have any suggestions or improvements, feel free to submit a pull request or open an issue.
If you have any feedback, questions, or suggestions, feel free to reach out.
connect me at [email protected]
or can DM me on LinkedIn.