FOLDER_RESOURCE_KEY: Khoá tài nguyên của thư mục mẹ.
USER_ID: Mã hồ sơ giúp xác định duy nhất người dùng.
Ứng dụng của bạn phải thực hiện yêu cầu này bằng cách làm theo các bước sau:
Xác minh rằng trường action có giá trị là create.
Sử dụng giá trị userId để tạo một phiên mới cho người dùng. Để biết thêm thông tin về người dùng đã đăng nhập, hãy xem bài viết Người dùng và sự kiện mới.
Sử dụng phương thức files.create để tạo tài nguyên tệp. Nếu bạn đã đặt folderId trên yêu cầu, hãy đặt trường parents thành giá trị folderId.
Tham số state được mã hoá bằng URL, vì vậy, ứng dụng của bạn phải xử lý các ký tự thoát và phân tích cú pháp dưới dạng JSON.
Người dùng và sự kiện mới
Ứng dụng Drive nên coi tất cả sự kiện "tạo" là các lượt đăng nhập tiềm năng. Một số người dùng có thể có nhiều tài khoản, vì vậy, mã nhận dạng người dùng trong tham số state có thể không khớp với phiên hiện tại. Nếu mã nhận dạng người dùng trong thông số state không khớp với phiên hiện tại, hãy kết thúc phiên hiện tại cho ứng dụng và đăng nhập dưới dạng người dùng được yêu cầu.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-02-24 UTC."],[[["When a user creates a new file with your app from Drive UI, your app receives a `state` parameter containing action, folder details, and user ID."],["Your app should verify the `action` is \"create\", create a user session, and use the provided information to create a new file via the Drive API."],["All \"create\" events should be treated as potential sign-ins and handled to accommodate users with multiple accounts, potentially requiring session switching."],["The `state` parameter is URL-encoded and needs to be parsed as JSON by your application for proper data extraction."]]],["When a user selects an app via Drive UI's \"New\" button, Drive redirects to the app's New URL, sending a `state` parameter. The `state` includes `action` (set to \"create\"), `folderId`, `folderResourceKey`, and `userId`. The app must verify the `action`, initiate a new user session based on `userId`, use `files.create` to generate a file resource, and handle `folderId` and `folderResourceKey`. All \"create\" events should be treated as potential sign-ins, with user sessions adjusted accordingly. The `state` parameter is URL-encoded JSON and must be parsed.\n"]]