# OneDraiveに連携する方法 MSAL(認証) + requests(HTTP)のみです。 これでMicrosoft GraphのOneDrive APIを直接叩けます ## 事前準備(無料) * アカウント - Microsoft アカウント(個人 OneDrive) - Microsoft Entra ID(旧Azure AD:OneDrive for Business)。 - どちらでも Graph 経由で同じコードが使えます。 * アプリ登録(Azure Portal) * https://azure.microsoft.com/ja-jp/get-started/azure-portal * Azure Portal → App registrations → New registration * サポートするアカウント種別は簡単のため “common” 相当(個人/組織どちらもOK)を選ぶと便利 * リダイレクトURIは不要(後述のデバイスコードフローならクライアントIDだけでOK) * Authentication で Mobile and desktop flows(Public client) を有効化(Device Code Flow用)。 * App registrationsで選択する * 左メニューのAuthentication * Mobile and desktop flows(Public client)を有効にする * API permissions に Microsoft Graph → Delegated で最低限 * Files.ReadWrite(ユーザーのファイルを読み書き) * offline_access(リフレッシュ/長期トークン) * User.Read(基本プロフィール) ## ライブラリをインストール ```sh pip install msal requests ```