{"id":13905782,"url":"https://github.com/harrisoff/onedrive-js-sdk","last_synced_at":"2025-07-18T03:31:30.766Z","repository":{"id":57115238,"uuid":"422803215","full_name":"harrisoff/onedrive-js-sdk","owner":"harrisoff","description":"Wraps some of OneDrive's APIs, only for uploading and sharing files.","archived":false,"fork":false,"pushed_at":"2022-09-12T15:32:07.000Z","size":211,"stargazers_count":14,"open_issues_count":1,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-20T14:07:34.319Z","etag":null,"topics":["image-hosting","imagehost","onedrive","onedrive-api","onedrive-sdk"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/harrisoff.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-30T06:30:27.000Z","updated_at":"2024-08-06T18:01:16.000Z","dependencies_parsed_at":"2022-08-22T11:10:10.295Z","dependency_job_id":null,"html_url":"https://github.com/harrisoff/onedrive-js-sdk","commit_stats":null,"previous_names":["harrisoff/onedrive-api"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harrisoff%2Fonedrive-js-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harrisoff%2Fonedrive-js-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harrisoff%2Fonedrive-js-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harrisoff%2Fonedrive-js-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/harrisoff","download_url":"https://codeload.github.com/harrisoff/onedrive-js-sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226336681,"owners_count":17608877,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["image-hosting","imagehost","onedrive","onedrive-api","onedrive-sdk"],"created_at":"2024-08-06T23:01:23.598Z","updated_at":"2025-07-18T03:31:30.754Z","avatar_url":"https://github.com/harrisoff.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# OneDrive JS SDK\n\n[![ts](https://badgen.net/badge/Built%20With/TypeScript/blue)](https://github.com/microsoft/TypeScript)\n[![npm version](https://badge.fury.io/js/@harrisoff%2Fonedrive-js-sdk.svg)](https://www.npmjs.com/package/@harrisoff/onedrive-js-sdk)\n![license](https://img.shields.io/npm/l/@harrisoff/onedrive-js-sdk)\n\nThis project wraps a small part of OneDrive's APIs, only for uploading files and creating sharing links.\n\nYou can build a webGUI to use it. There is an example [OneDrive Image Hosting](https://github.com/harrisoff/onedrive-image-hosting).\n\n[中文文档](./README.zh-cn.md)\n\n## Configure Account\n\nIn [App registrations](https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade) page click *new registration* button, then you'll need to fill the following fields:\n\n- Name\n\n- Supported account types\n\n   `Personal Microsoft accounts only` is enough for personal usage\n\n- Redirect URI\n\n   For example, `https://localhost:3000/`\n\nAfter registration, click *Authentication* on the left, check `Access tokens (used for implicit flows)` and save.\n\n`Application (client) ID` is generated once the application is registered. But you'll need to verify the application before using it. Just click *Branding* on the left and follow the instructions.\n\n## Usage\n\n### Authentication\n\nHere we use [token flow](https://docs.microsoft.com/en-us/onedrive/developer/rest-api/getting-started/graph-oauth?view=odsp-graph-online#token-flow) in authentication. Use helper function `generateAuthUrl` to generate an auth url and open it.\n\n```ts\nimport { generateAuthUrl } from '@harrisoff/onedrive-js-sdk'\n\nconst authUrl = generateAuthUrl('your-client-id', 'your-redirect-uri')\n```\n\n\u003e Actually there's another field `scope` is required in the auth url.\n\u003e This value is set to `openid https://graph.microsoft.com/Files.ReadWrite.All`\n\u003e and is unnecessary to be changed.\n\nAfter redirecting back to your site, `access_token` or error messages will be presented in the hash depending on whether authentication is successful.\n\n### API calls\n\nThere are two ways to call APIs.\n\nThe original APIs are exposed so you can use them directly:\n\n```ts\nimport { uploadSmall, createUploadSession, uploadLargeChunk, share, getShareItem } from '@harrisoff/onedrive-js-sdk'\n```\n\nOr you can use constructor to create a client instance, which wraps the original APIs:\n\n```ts\nimport OneDriveAPI from '@harrisoff/onedrive-js-sdk'\n\nconst client = new OneDriveApi({ accessToken })\nconst { id: fileId } = await client.upload(file, filePath)\nconst { shareId } = await client.share(fileId)\nconst shareUrl = await client.getShareUrl(shareId)\n```\n\n## TODO List\n\n- [ ] progress callback\n\n## Development\n\nFor more details, see:\n\n- [Official OneDrive API Document](https://docs.microsoft.com/en-us/onedrive/developer/)\n- [some notes for my personal reference](./NOTES.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharrisoff%2Fonedrive-js-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharrisoff%2Fonedrive-js-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharrisoff%2Fonedrive-js-sdk/lists"}