Microsoft Fluent GraphAPI
Install
pnpm i msgraphapi
Docs(VitePress)
pnpm run docs:dev
Build
pnpm run build
Usage
Login
import { GraphAPI , ConflictBehavior } from "msgraphapi"
const graphAPI = new GraphAPI({
clientId: '{clientId}',
scoped: [PermissionScope.UserReadWrite,PermissionScope.FilesReadWriteAll]
})
// login first: redirect or popup
graphAPI.loginAsync().then(res=>{
console.log(res)
})
OneDrive
let drive = graphAPI.drive("{driveId|me}")
// fluent call
drive.item("{itemId}").path("{relative path}").getAsync()
// clone context, get FileOrFolder info
drive.clone().item("{itemId2}").path("{relative path}").getAsync()
console.log(drive.itemId)
// cnosole result: {itemId}
// create folder
drive.clone().item().createListAsync({
name: "folder",
conflict: ConflictBehavior.Fail
})
LICENSE
MIT